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

Remote Event suppose to change leaderstat but not working?

Asked by 5 years ago
Edited 5 years ago

So I have a GUI & a Remote Event. Whenever you click a button it should get the text of a text box pass it as a perimeter and fire an event that should change your leaderstats value of honor to honor.Value = honor.Value + 1 but doesn't seem to be working.

Local Script Script Inside of the GUI:

local Name = script.Parent:WaitForChild("Name")
local HonorButton = script.Parent:WaitForChild("HonorButton")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player
local Event

HonorButton.MouseButton1Click:Connect(function()
    Event = ReplicatedStorage:FindFirstChild("EN1")

    if Event ~= nil then
        Player = Name.Text
        wait(1)
        Event:FireServer(Player)
    end
end)

Server Script Script inside of the Remote Event:

script.Parent.OnServerEvent:Connect(function(Player)
    for _,v in pairs(game.Players:GetPlayers()) do
        if v.Name == Player then
            if Player.leaderstats then
                Player.leaderstats["Honor"].Value = Player.leaderstats["Honor"].Value + 1
            end
        end
    end
end)
0
Why do you have a script inside of a RemoteEvent? Also, RemoteEvents automatically pass the player who called them. You should be catching (player Instance, playerName String). SummerEquinox 643 — 5y
0
I have a script inside a Remote Event because I want a script inside a Remote Event. namespace25 594 — 5y
0
Also, do you mean sometime like this in the Remote Event Script "script.Parent.OnServerEvent:Connect(function(called,Player)" namespace25 594 — 5y
0
Yeah, I'm pretty sure that in your server script Player is representing the player instance of the player who called it - not the string you are passing. SummerEquinox 643 — 5y
View all comments (2 more)
0
Still doesn't work. namespace25 594 — 5y
0
scripts don't run in replicatedstorage User#22604 1 — 5y

Answer this question