Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago

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)
0
you can only use: if hit then yHasteeD 1819 — 5y
0
works perfectly fine Ziffixture 6913 — 5y
0
The value doesn't change. sbob12345m 59 — 5y
0
What do you want to do change to? Ziffixture 6913 — 5y
View all comments (3 more)
0
If false then why are you saying true in the OnTouched function, change to false Ziffixture 6913 — 5y
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. sbob12345m 59 — 5y
0
Oh, no don’t be using a LocalScript!! They only run inside PlayerObjects, change it to a ServerScript Ziffixture 6913 — 5y
Ad

Answer this question