here is the script - it is in a local script in the part that is being touched
local player = game.Players.LocalPlayer
script.Parent.Touched:Connect(function()
player.PlayerGui.Win.Enabled = true
end)
here is the script - it is in a local script in the part that is being touched
local player = game.Players.LocalPlayer
script.Parent.Touched:Connect(function()
player.PlayerGui.Win.Enabled = true
end)
Normal script inside part:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:WaitForChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.PlayerGui.Win.Enabled = true
end
end)
I used a normal script here because local scripts only work in ReplicatedStorage, StarterGui and StarterPlayer.
I am not sure if your way is correct, this is my way how to do it
script.Parent.Touched:Connect(function(Hit) -- The hit object called HIt
if Hit.Parent:FindFirstChild("Humanoid") then -- IT IS A PLAYER ! DO SOMETHING!
local Player = Hit.Parent:GetPlayerFromCharacter(Hit.Parent)
Player.PlayerGui.Win.Enabled = true
end
end)
Wrong.
Line 3 is wrong. Use mine(the one below this).
Welp fixed it lol
it didn't work. I changed the script to a normal script but still didn't work...
Keep it in the LocalScript. I'm assuming you renamed your ScreenGui to Win. You may want to try this method:
local Gui = game.StarterGui.Win.ImageButton -- If there's not an ImageButton, then change it to whatever it is inside of Win. ImageButton was just an example, but keep it if it's actually an ImageButton that a player is looking at.
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if Gui.Visible = false then
Gui.Visible = true
end
end
end)
Hope this helps!
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
yes that works :)
Could you please accept this as an answer then?