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

It don't reacts to my remote event or does my script don't work?

-- local script

game.ReplicatedStorage.PagerSoundEvent.OnClientEvent:connect(function()
	if game.Players.LocalPlayer.Backpack:FindFirstChild("Pager") then
		game.Players.LocalPlayer.PagerSound:Play()
		wait(7)
		game.Players.LocalPlayer.PagerSound:Stop()
		end
end)

so this is in StarterPlayerScripts

-- normalscript in workspace

local player = game.Players.LocalPlayer

if script.Parent.Sound.Value == true then
		game.ReplicatedStorage.PagerSoundEvent:FireServer()
		wait(1)
		script.Parent.Sound.Value = false
	end

This is in workspace but if i turn the sound value on then it don't react without any errors. I used 1 breakpoint at script 2 line 6 but it didn't work? Someone that could help me?

1 comment

0

There's multiple things wrong with your code: 1.) A RemoteEvent isn't used for client-to-client communication, it's used for server-to-client communication 2.) LocalScripts don't run when parented to workspace

1 answer

✓ Accepted answer
  1. A remote event is used only for SERVER to CLIENT communication.

  2. Only ServerScripts run when in workspace.

  3. this should work

-- local script

game.ReplicatedStorage.PagerSoundEvent.OnClientEvent:connect(function()
    if game.Players.LocalPlayer.Backpack:FindFirstChild("Pager") then
        game.Players.LocalPlayer.PagerSound:Play()
        wait(7)
        game.Players.LocalPlayer.PagerSound:Stop()
        end
end)

-- normalscript in workspace
local rep = game:GetService("ReplicatedStorage")

if script.Parent.Sound.Value == true then
        rep:WaitForChild("PagerSoundEvent"):FireClient()
        wait(1)
        script.Parent.Sound.Value = false
    end

2 comments

0

ServerScripts also run in ServerScriptService, not only in Workspace.

0

I know... He used localscript in workspace lol. That's why i said only server scripts run in workspace.

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