Can someone help i dont get it so every time i touch this part it warns me fireserver can only be called from the client
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then game.ReplicatedStorage.Events.Sell:FireServer() end end)
Hello Gingerely
Thanks for the question
Basically, because I guess you're using a server script, inside of a part, you can just do everything here, as the serverscript is safe, and the client can not edit this, meaining you will not need to fire the server.
RemoteEvents, allow the server and the Client to interact / communicate.
Since you're already using a serverscript, you can do this
local debounce = false script.Parent.Touched:Connect(function(hit) if debounce == false then -- checking for debounce debounce = true -- because player has touched. if hit.Parent:FindFirstChild("Humanoid") then -- has found a player. local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) -- gets the player inside of the 'Players' service. --Add the players currency here example; player.leaderstats["Currency2"].Value = player.leaderstats["Currency1"].Value * 2 --EXAMPLE. player["Currency1"].Value = 0 --EXAMPLE. wait(2) debounce = false end end end)
This must be server script then, change it to a Local Script!