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

somebody hit the part script does something for some reason is not working does not show any errors?


script.Parent.Touched:Connect(function(hit)


		local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
		local cash = plr.leaderstats.Cash
	cash.Value = cash.Value +5
		R:FireAllClients()
		print('Recived')

	end)


---This part it is in Replicated storage, I made a script that when you click a part, the part in replicated storage (this one) duplicates and goes to Workspace and when a player hits it what it says in the script is what it does. But is not doing anything.

10 comments

0

wait so what does that script do exactly?

0

im guessing it gives cash to someone and does someone else on all clients

0

It deletes a part that the player has in its right hand, gives player 5 more of cash, fire a remote event and destroy its parent.

0

and it just does nothing?

0

Yeah, wait, I changed something but it still does not work

0

u cant give cash in a localscript

0

Is in a script.

0

a script in a brick?

0

well still it has to fire a remote event to the server and from there u can manage the currency

0

Is in a brick, also the remote event connects to 4 localscripts.

1 answer

✓ Accepted answer

just use a new remote event to fire to the specific user for the cash

script.Parent.Touched:Connect(function(hit)


        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        local cash = plr.leaderstats.Cash
    NewEvent:FireServer
        R:FireAllClients(plr)
        print('Recived')

    end)


script in serverScriptService

NewEvent.OnServerEvent:Connect (function(player)
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 5
end)

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