I want a value to enable when the puck touches the stick heres what I have. The value is a Bool Value by the way. The script is a local
1 | script.Parent.Touched:connect( function (Part) |
2 | if Part.Name = = "ball" then |
3 | game.StarterPack.stick.HasPuck.Value = true |
4 | end |
Whenever I touch the puck with the stick it dosen't enable. Is it not possible to do this?
It is very possible to do this, and is actually quite simple.
Instead of trying to find the value from StarterPack, I put the script in the puck and set the var bool to script.Parent.HasBall(the name of the bool). I then made a Touch function and here we are.
Make Sure The Script is not local
01 | --Setting Variables |
02 | local Stick = script.Parent |
03 | local bool = script.Parent.HasBall |
04 |
05 | local puck = workspace.Ball |
06 |
07 | --Setting the bool Value to false(I am pretty sure this is not required) |
08 | bool.Value = false |
09 | print ( "bool is false" ) |
10 |
11 | --The function |
12 | puck.Touched:Connect( function (hit) |
13 | if hit = = Stick or hit.Parent = = Stick then |
14 | bool.Value = true |
15 | print ( "bool is true" ) |
16 | end |
17 | end ) |