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 4 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:

script.Parent:GetPropertyChangedSignal("Value"):Connect(function()
    print(script.Parent.Value)
    local val = script.Parent.Value
    if val == 0 then
        print"is 0"
        game.ReplicatedStorage.RemoteEvent:FireAllClients()
        print("fired")
    end
end)

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

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
    print("finally")
    local plr = game:GetService("Players").LocalPlayer
    local char = plr.Character
    script.Parent.Value = 10
    char.Humanoid.WalkSpeed = 0
    wait(.5)
    char:MoveTo(Vector3.new(-20.55, 19.9, -6.46))
    game.Workspace.Map1.Dots:Destroy()
    local ss = game:GetService("ServerStorage")
    local newdot = ss.Dots:Clone()
    newdot.Parent = game.Workspace.Map1
    wait(4.4)
    char.Humanoid.WalkSpeed = 16
end)

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 — 4y

1 answer

Log in to vote
2
Answered by 4 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 — 4y
Ad

Answer this question