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

Script works in local server but not in team test/server?

I'm new to scripting, and I'm probably overlooking something simple here. I'm making a brick that when touched teleports you to a new area. This script works perfectly fine in a local server, but not in a team test or actual server. I do know that in an actual server the client is separated from the server, but I'd like to have an explanation on why this doesn't work. Any help is greatly appreciated.

function onTouched(hit)
local plr = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if plr then
plr.PlayerGui.Pop:Play()
plr.Character.Torso.CFrame = CFrame.new(-9999, 0 , -9999)
	end
end

script.Parent.Touched:Connect(onTouched)

3 comments

0

PlayerGui cannot be accessed from the server.

0

Thanks. So what would be a workaround to that?

0

Place the sound elsewhere.

1 answer

Put a RemoteEvent in ReplicatedStorage and remplace line 4 for that

game.ReplicatedStorage.RemoteEvent:FireClient(Player)

add a LocalScript in StarterGui with ur sound and write this.

local debounce = true

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
	if debounce then
		debounce = false
		script.Parent.Pop:Play()
		wait(1)
		debounce = true
	end
end)

1 comment

0

Or he can skip all this and just place the sound in replicatedstorage?

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