Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a bool value change when the puck touches the script?

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

script.Parent.Touched:connect(function(Part)
  if Part.Name == "ball" then
	game.StarterPack.stick.HasPuck.Value = true
end

Whenever I touch the puck with the stick it dosen't enable. Is it not possible to do this?

2 comments

0

is this a localscrit

0

yes

1 answer

✓ Accepted answer

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

--Setting Variables
local Stick = script.Parent
local bool = script.Parent.HasBall

local puck = workspace.Ball

--Setting the bool Value to false(I am pretty sure this is not required)
bool.Value = false
print("bool is false")

--The function
puck.Touched:Connect(function(hit)
	if hit == Stick or hit.Parent == Stick then
		bool.Value = true
		print("bool is true")
	end
end)

5 comments

0

it isnt working

0

Is it in a server script or local

0

server

0

Maybe add me on disc my disc is JR#0542

0

Okay

This discussion is preserved as it was. New answers, comments, and votes are closed.