Small mistake, you're trying to edit a gui from the StarterGui, which doesn't work. The StarterGui just places guis on the player's screen once they join. If you want to edit a player's gui you have to edit it from the PlayerGui, which would be located with game.Players["PlayerNameHere"].PlayerGui. A little bit of extra work is required to do that effectively though.
We're gonna have to dabble into RemoteEvents, which allow for communication between server and client sided scripts. Even if you can, avoid editing player's guis server sided. Assuming that the part your script is in is a server script, we're gonna have to 1: Create the remote event, 2: Get the player who touched the part and affect their gui.
local rs = game:GetService("ReplicatedStorage")
local event = Instance.new("RemoteEvent")
event.Name = "IceCreamGuiEvent"
event.Parent = rs
function onTouched(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
event:FireClient(player)
wait(6.1)
script.Parent:Destroy()
end
end
script.Parent.Touched:Connect(onTouched)
Now this next part should be in a localscript in StarterPlayerScripts (which is below StarterPlayer).
local rs = game:GetService("ReplicatedStorage")
local event = rs:WaitForChild("IceCreamGuiEvent")
local player = game.Players.LocalPlayer
local pgui = player.PlayerGui
event.OnClientEvent:Connect(function()
pgui.IceCream.Up_On_The_Chocolate.Visible = true
wait(6)
pgui.IceCream.Up_On_The_Chocolate.Visible = false
end)
1 comment
ty