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

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

Asked by
1VoyX 5
6 years ago

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)
0
PlayerGui cannot be accessed from the server. User#19524 175 — 6y
0
Thanks. So what would be a workaround to that? 1VoyX 5 — 6y
0
Place the sound elsewhere. User#19524 175 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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)
0
Or he can skip all this and just place the sound in replicatedstorage? DevingDev 346 — 6y
Ad

Answer this question