Trampoline Coding C#

using UnityEngine;
using System.Collections;

public class Trampoline : MonoBehaviour {

	float bounceAmount = 10;
	bool bounce = false;
	public Transform Player; 
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	if(bounce) {
			Player.rigidbody.velocity.y = 0;
			Player.rigidbody.AddForce(0,bounceAmount,0,ForceMode.Impulse);
			bounce = false;
		}
	}

	void OnCollisionEnter (Collision other) {
		if(other.gameObject.name == "Player") {
			bounce = true;

		}
	}
}

I get this error:
Assets/Scripts/Trampoline.cs(16,42): error CS1612: Cannot modify a value type return value of `UnityEngine.Rigidbody.velocity’. Consider storing the value in a temporary variable

The idea is to create an bouncy trampoline in a adventure game.
Im not that skilled to programming, and this code was a piece of JavaScript which i had to translate to C#. Anyone that could help me?

This may work in UnityScript, but C# needs it an other way:

var velocity = Player.rigidbody.velocity.y = 0;
velocity.y = 0;
Player.rigidbody.velocity = velocity;

or

Player.rigidbody.velocity *= new Vector3(1, 0, 1)

The reason for this is, that velocity is a Property with a setter and getter, the getter gives you a copy of the underlying Vector3, changing this copy will have no affect on the real velocity. And thats why the C# compiler will nag about it.

Vector3 is a value type (struct) and value types will be returned as copy (return value, input parameter, eg.). The opposite are reference values (class) which will be references and not clones/copies, when a method/getter returns these you can manipulate the original by working on the members of it.

Why is UnityScript able to handle these? The unityScript compiler is able to detect what you want and will create a temporary variable on which the changes will be done and will then set this temporary variable back to the original value (by calling the setter of the property). UnityScript is comfortabler to use, but you dont know what will happen behind the scenes (in fact you may know it by looking into IL code, and what US is doing there is really really ugly and… bullshit).