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

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

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)

2 comments

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.

0

DONT USE game.StarterGUI you need use player.PlayerGUI

1 answer

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)

3 comments

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...

0

I missed out something.

0

Still when I click it it dose nothing.

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