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

My Remote Event won't work properly???

Asked by 5 years ago

Basically I sent the remote event and I know thats working, is there anything wrong in this script??

debounce = false

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local GuiClicker = ReplicatedStorage:WaitForChild("GuiClicker")
local playerGui = player:WaitForChild("PlayerGui")


local function OnGuiClickerFired(plr)
    if debounce == false then

        plr.playerGui.InfoPanel.ScrollingFrame:TweenPosition(UDim2.new(0.5, -250,0.5, -200, 'Out', 'Bounce', 1))
    debounce = true
    else
    plr.playerGui.InfoPanel.ScrollingFrame:TweenPosition(UDim2.new(-0.5, -250,0.5, -200, 'Out', 'Bounce', 1))
    debounce = false
      plr.playerGui.InfoPanel.ScrollingFrame.Visible = true
        debounce = false
end
end

GuiClicker.OnClientEvent:Connect(OnGuiClickerFired)

0
Why are you defining plr in line 10 when you did this on line 5? User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by
mattscy 3725 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

The first parameter of OnClientEvent is not the player, as you can just get the player through game.Players.LocalPlayer in a LocalScript. However, when you fire a remote event to the server, the server doesn't know which player has fired it, so the first argument of OnServerEvent will be the player in that case. So, all you should have to do is remove the Plr as an argument, and just use the player variable from above to refer to the LoclPlayer. Also, PlayerGui is with a capital P, and capitalisation matters in Lua. If you are not referring to the PlayerGui through the player, you can use your lowercase p playerGui variable from above.

For example:

local debounce = false

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = Players.LocalPlayer
local GuiClicker = ReplicatedStorage:WaitForChild("GuiClicker")
local playerGui = player:WaitForChild("PlayerGui")


local function OnGuiClickerFired()
    if debounce == false then

        playerGui.InfoPanel.ScrollingFrame:TweenPosition(UDim2.new(0.5, -250,0.5, -200, 'Out', 'Bounce', 1))
        debounce = true
    else
        playerGui.InfoPanel.ScrollingFrame:TweenPosition(UDim2.new(-0.5, -250,0.5, -200, 'Out', 'Bounce', 1))
        playerGui.InfoPanel.ScrollingFrame.Visible = true
        debounce = false
    end
end

GuiClicker.OnClientEvent:Connect(OnGuiClickerFired)

You might also want to check if you are setting Visible to true in the right section.

0
ye User#19524 175 — 5y
Ad

Answer this question