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

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

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.

6 comments

0

I evened tried to remove the locals from the localscript but that didn't work.

1

You don't need to pass the player through :FireServer, since roblox does this for you already.

0

Ok, if I remove the plr from the localscript in the :FireServer thing, it still isn't fixed.

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");

0

Nope. The server doesn't receive the request. I made a print and it didn't show anything in the output.

0

Is the script inside the RE, i'm guessing it is

1 answer

✓ Accepted answer

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

1 comment

0

Oh shoot of course I forgot about that detail. Thanks.

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