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

Remote Event not functioning properly?

Asked by 5 years ago

My first script detects a change in an int value's value. When the value becomes 0, it fires a remote event to the client. Server script:

1script.Parent:GetPropertyChangedSignal("Value"):Connect(function()
2    print(script.Parent.Value)
3    local val = script.Parent.Value
4    if val == 0 then
5        print"is 0"
6        game.ReplicatedStorage.RemoteEvent:FireAllClients()
7        print("fired")
8    end
9end)

The problem is, is that it doesn't fire the event. Here's my local script:

01game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
02    print("finally")
03    local plr = game:GetService("Players").LocalPlayer
04    local char = plr.Character
05    script.Parent.Value = 10
06    char.Humanoid.WalkSpeed = 0
07    wait(.5)
08    char:MoveTo(Vector3.new(-20.55, 19.9, -6.46))
09    game.Workspace.Map1.Dots:Destroy()
10    local ss = game:GetService("ServerStorage")
11    local newdot = ss.Dots:Clone()
12    newdot.Parent = game.Workspace.Map1
13    wait(4.4)
14    char.Humanoid.WalkSpeed = 16
15end)

I have no clue why this doesn't work.

0
Add a print statement in global scope (i.e. at the top of the local script) and make sure it runs. f59ph_iv 0 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago

The code looks solid, is your script in replicatedstorage, and is your localscript in replicatedstorage or workspace?

0
My remote event is in replicated storage. My local script is in the intvalue in workspace. My script is also in the same int value. https://gyazo.com/1365179ee00d8ade6045a2adfbfc8e6f XxOPGUYxX1234567 221 — 5y
Ad

Answer this question