Hello, today I am trying to make a dollar where when the player clicks the dollar adds to the player's wallet everything is fine but I can't use a remote function with server scripts

to go more into the basis of the situation I have a dollar and it's linked to a click detector when the player clicks it's supposed to trigger the remote function but the issue is that remote functions are client-server relationship and scripts are server and you cant have local scripts in workspace to trigger the remote function

so my question is how can I get my script to trigger the remote function then return a value

my code for the dollar in workspace, IT ISA A SCRIPT NOT LOCAL SCRIPT:

local dollar = script.Parent
local replicatedStorage = game:GetService("ReplicatedStorage")

local clickdetector = dollar.ClickDetector

clickdetector.MouseClick:Connect(function(player)
	local money = replicatedStorage.moneyGrabRemoteEvent:InvokeServer(player, 100000)
	dollar:Destroy()
end)

EDIT: figured it out i used a local script in starter playerscripts to detect the click detector in workspace then i used the event ty

6 comments

0

Code blocks please. There is a random ad in the middle of your code because it is not in code blocks

0

Remove local money= but keep what's after

0

You'd have to create a remote event that went to the server, as there's no parameter for clickdetectors.

0

You can change the values from a ServerScript.

0

code blocks ok im sorry king, spj i tried didnt work, penguin i did i think?, youtube thanks i just figure out about fireserver ty, still needing help >.<

0

figured it out i used a local script in starter playerscripts to detect the click detector in workspace then i used the event ty