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

OnPart function won't change the value of a boolvalue?

When a player walks over a spawn it sets a bool value (IsInMatch) to false. When the bool value is set to true the GUI is Invisible, but when the boolvalue is false the GUI is visible. Although, that's not the problem. the problem is that when I walk over my spawn, it won't change the value of the boolvalue, hence letting the GUI not disappear.

here is the local script inside the spawn:

local IsInMatch = game.Players.LocalPlayer.IsInMatch

function OnTouch(part)
	IsInMatch.Value = true
end

1 answer

There's not Touched event to allow the function to Run, write this to solve your issue

local IsInMatch = game.Players.LocalPlayer.IsInMatch

function OnTouch(part)
    IsInMatch.Value = true
end

local Spawn = script:FindFirstAncestor("Spawn")
Spawn.Touched:Connect(function(hit)
   if (hit ~= nil) then
      OnTouch(Spawn)
   end
end)

7 comments

0

you can only use: if hit then

0

works perfectly fine

0

The value doesn't change.

0

What do you want to do change to?

0

If false then why are you saying true in the OnTouched function, change to false

0

I switched it to false, still doesn't work. My game is filtering enabled and the script inside the spawn is a local script.

0

Oh, no don’t be using a LocalScript!! They only run inside PlayerObjects, change it to a ServerScript

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