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

Why won't anything happen when i click the button?

Asked by
Xyternal 247 Moderation Voter
3 years ago

So I was experimenting with remoteEvents, and I was trying to make it so everytime the player clicks the button, he gets one point. But I get multiple errors doing so. Here is my local script

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvenTest")
    local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
    plr.leaderstats.Kills.Value = plr.leaderstats.Kills.Value + 1

remoteEvent:FireServer()

and here is my serverscript

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvenTest")
function hi()
    game.Workspace.d.BrickColor = BrickColor.new("Lavender")

end
function die()
    remoteEvent.OnServerEvent:Connect(hi)
end
script.Parent.dd.MouseClick:Connect(die)

Sorry for my weird variables, but what have i dont wrong?

1 answer

Log in to vote
0
Answered by 3 years ago
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvenTest")
    local plr = game.Players:GetPlayerFromCharacter(script.Parent.Parent)
    plr.leaderstats.Kills.Value = plr.leaderstats.Kills.Value + 1

remoteEvent:FireServer()

this isnt function

0
I dont see the difference in the scripts... Xyternal 247 — 3y
0
whats supposed to be the point of your answer? Xyternal 247 — 3y
0
I dont get your answer. The code is exactly the same, so can you elaborate a bit more? Xyternal 247 — 3y
Ad

Answer this question