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

There is something wrong with this click script I'm making with a remote event?

Asked by 5 years ago

I'm working on a small clicker game and my biggest issue right now is actually adding the currency when the button is clicked. I don't see anything issues here but maybe someone can find it because I've had this issue for a lot of other games I've done.

My localscript for the button.

local add = game.ReplicatedStorage.Remotes.ClickEvent
local plr = game.Players.LocalPlayer
local lstats = plr:WaitForChild("leaderstats")
local ice = lstats:WaitForChild("Ice").Value
local click = lstats:WaitForChild("Ice per Click").Value
local gui = script.Parent
gui.MouseButton1Click:Connect(function()
    add:FireServer(plr)
end)
gui.MouseEnter:Connect(function()
    gui:TweenSizeAndPosition(UDim2.new(0.6,0,0.8,0),UDim2.new(0.4,0,0.2,0),"Out","Quint",0.25)
end)
gui.MouseLeave:Connect(function()
    gui:TweenSizeAndPosition(UDim2.new(0.45,0,0.6,0),UDim2.new(0.475,0,0.3,0),"Out","Quint",0.25)
end)

My script for the remote event.

script.Parent.OnServerEvent:Connect(function(plr)
    local lstats = plr:FindFirstChild("leaderstats")
    local click = lstats:FindFirstChild("Ice per Click")
    local ice = lstats:FindFirstChild("Ice")
    ice.Value = ice.Value+click.Value
end)

It just doesn't seem to work ad I can't find the issue because there is no issue in the output.

0
I evened tried to remove the locals from the localscript but that didn't work. IceBoltGamingIBG 9 — 5y
1
You don't need to pass the player through :FireServer, since roblox does this for you already. User#24403 69 — 5y
0
Ok, if I remove the plr from the localscript in the :FireServer thing, it still isn't fixed. IceBoltGamingIBG 9 — 5y
1
Did I say it would fix the problem? No. It just removes redundancy. In the server script call print. See if there's any output. Like print("The server received request"); User#24403 69 — 5y
View all comments (2 more)
0
Nope. The server doesn't receive the request. I made a print and it didn't show anything in the output. IceBoltGamingIBG 9 — 5y
0
Is the script inside the RE, i'm guessing it is User#28794 0 — 5y

1 answer

Log in to vote
0
Answered by
Imperialy 149
5 years ago

ServerScripts do not run in replicatedstorage, you will have to put the script in serverscriptservice and fix up your variables

0
Oh shoot of course I forgot about that detail. Thanks. IceBoltGamingIBG 9 — 5y
Ad

Answer this question