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

Why is my Remote Evant not working? There is also no errors when I run it.

Asked by 5 years ago

My remote event does not work for some reason. I get no errors.

When I click the button it does not do what I programmed it to do. Here is the code.

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
  local Frame = game.StarterGui.JumpCounter.Frame
Frame.Trail1.MouseButton1Click:Connect(function()
Frame.Visible = true    
if game.Players.LocalPlayer.leaderstats.Jumps.Value >= 50 then
script.Parent.Parent.Frame.Trail1.Visible = true
else
    script.Parent.Parent.Frame.Trail1.Visible = false
if game.Players.LocalPlayer.leaderstats.Jumps.Value >= 100 then
script.Parent.Parent.Frame.Trail1.Visible = true
script.Parent.Parent.Frame.Trail2.Visible = true 
else
    script.Parent.Parent.Frame.Trail1.Visible = false
    script.Parent.Parent.Frame.Trail2.Visible = false
end
end
end)

end)

Code in the button:

script.Parent.MouseButton1Click:Connect(function(plr)
    game.ReplicatedStorage.RemoteEvent:FireServer(plr)
end)
0
Localplayer isn't a thing on a normal script. Don't need to pass in 'plr' in your local script since that's provided automatically. Don't think you can add events to stuff like StarterGui and expect it to affect the actual player. ScrewDeath 153 — 5y
0
DONT USE game.StarterGUI you need use player.PlayerGUI FrezeTagger 75 — 5y

1 answer

Log in to vote
0
Answered by
Prestory 1395 Moderation Voter
5 years ago
Edited 5 years ago

The Server Script looks fine although one thing i noticed about it you need to access the gui through plr.PlayerGui instead of game.StarterGui

game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr)
  local Frame = plr.PlayerGui.JumpCounter.Frame
Frame.Trail1.MouseButton1Click:Connect(function()
Frame.Visible = true    
if game.Players.LocalPlayer.leaderstats.Jumps.Value >= 50 then
script.Parent.Parent.Frame.Trail1.Visible = true
else
    script.Parent.Parent.Frame.Trail1.Visible = false
if game.Players.LocalPlayer.leaderstats.Jumps.Value >= 100 then
script.Parent.Parent.Frame.Trail1.Visible = true
script.Parent.Parent.Frame.Trail2.Visible = true 
else
    script.Parent.Parent.Frame.Trail1.Visible = false
    script.Parent.Parent.Frame.Trail2.Visible = false
end
end
end)

end)


on the local script you don't need to pass plr through the args so it should be like this

script.Parent.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.RemoteEvent:FireServer()
end)

0
This should probably be a comment since, as you said, it isn't needed. Removing it won't really change anything in this case so it's not probable that this is an actual answer to OP's question... ScrewDeath 153 — 5y
0
I missed out something. Prestory 1395 — 5y
0
Still when I click it it dose nothing. appleprogamer_59 29 — 5y
Ad

Answer this question