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

Could you guys check my FE script because it is not working?

Local Script in the ClickDetector

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:FindFirstChild("MouseClicked")

local ClickDetector = script.Parent

local Debounce = false

ClickDetector.MouseClick:Connect(function()
	if not Debounce then
		Debounce = true
		local PlayerTrash = game.Players.LocalPlayer.leaderstats.Trash
		RemoteEvent:FireServer(PlayerTrash)
		wait(0.01)
		Debounce = false
	end
end)

OnEvent Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:FindFirstChild("MouseClicked")

RemoteEvent .OnServerEvent:Connect(function(Player, PlayerTrash)
	if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(Player.userId, 0000000) then
		PlayerTrash.Value = PlayerTrash.Value + ((1 * (Player.leaderstats.Rebirths.Value + 1)) * 2) -- change the "2" to the multiplying number
	else
		PlayerTrash.Value = PlayerTrash.Value + (1 * (Player.leaderstats.Rebirths.Value + 1))
	end
end)

3 comments

0

Probably because you're trying to :FireServer() on your "ClickDetector" object and not the RemoteEvent.

0

you wouldn't even need remote events for this, you can get the player through MouseClick's first parameter: playerWhoClicked

0

why not just fire the player variable and use it on your server script to access leaderstats

1 answer

✓ Accepted answer

Like people have stated before, you don't even need a remote event.

The click event's first argument is the player who clicked it

ClickDetector.MouseClick:Connect(function(arg1) -- being arg1 anything you want to call it
-- and it's value is the player who clicked it
end)

"LocalPlayer" does not work on server-sided scripts, only LocalScripts.

You can also inside of the "Click" function, run all the code you were using on the event script.

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