Money is going to everyone in the server

  1. What do you want to achieve? Keep it simple and clear!

I need to make the person going over the plate get money and not everyone

  1. What is the issue? Include screenshots / videos if possible!
    robloxapp-20221029-0213354.wmv (1.4 MB)

  2. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Yes I did look for solution, I am not knowing enought in stuff like that so it make it difficult to fix

game.Players.PlayerAdded:Connect(function(player)
	local Currency = player:WaitForChild("leaderstats"):WaitForChild("Currency")
	local be = game.ReplicatedStorage.MONEY
	be.Event:Connect(function(player)
		Currency.Value = Currency.Value + 5
	end)
end)

image
this is where it get fired

-------StartVariable-----
local part = script.Parent

local myfirstray = Ray.new(part.Position, Vector3.new(0, 50, 0))

local zamboniHit = false
local mat = Enum.Material.Ground

local be = game.ReplicatedStorage.MONEY
-------EndVariable-------

while wait(0.01) do
	local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(myfirstray, {part})
	if hit then 
		if hit.Material == mat then
			part.CanCollide = false
			part.Transparency = 1
			be:Fire()
			wait(5)
			part.CanCollide = true
			part.Transparency = 0
		end
	end


end
1 Like

You can instead do:

be = game.ReplicatedStorage.MONEY
be.Event:Connect(function(player)
	player:WaitForChild("leaderstats"):WaitForChild("Currency").Value += 5
end

Place this outside the “PlayerAdded” event.

1 Like

you are doing it wrong, there is a much better way to do this but here is your way

game.Players.PlayerAdded:Connect(function(player)
	local Currency = player:WaitForChild("leaderstats", 1/0):WaitForChild("Currency", 1/0)
	local be = game.ReplicatedStorage.MONEY
	
	be.Event:Connect(function(playerFrom)
		if playerFrom ~= player then
			return
		end
		
		Currency.Value = Currency.Value + 5
	end)
end)
1 Like

im gonna test that rn, thank you for reply

Thank you for ur reply, im gonna try that too !

now it look like to just not giving money anymore

doesn’t work, it doesn’t give money at all and there is no error in the console

fire the event for the specific person you want to give money to

eg:

if you have a player variable after they touch the part to give money,
you would do

event:FireServer(player)

if you dont know how to get a player from the touched part of the script, you do this

game.Players:GetPlayerFromCharacter(hit.Parent) – replace hit with whatever you set as the thing for your touched function

Thank you for replying, mind giving a bit more information or something I can read?

I don’t know much about event and wanna understand it better.

I’ll try that too btw thank you!

insert a part
put a script inside that part with the following script

script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
--(assuming you have something in the player, a leaderstat for this script, of their coins / money value)
local money = player.leaderstats.Coins
money.Value += 5 -- replace 5 with the amount of money you want to give
end)

i can help you setup a leaderstat for their money if you want

Place the

be.Event:Connect(function(player)
		Currency.Value = Currency.Value + 5
	end)

outside of the PlayerAdded function and make sure to put the player thats going over the plate in the Fire().

but you are using touched which is when it is touched? I use a ray because I don’t touch it but the car does or almost do.

I don’t know much on rays, but that’s how I would make a currency thing work

im gonna try that, thank you for helping me!

put

be:Fire(player) -- make a player variable in your script somewhere, one that links to the ray

yeah thats what im gonna try rn, just not sure of what im supposed to set the player as…

well whatever you do with the ray

the part there
once the ray is hit you should still be able to get the player from this

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

im gonna try this rn thank you

doesn’t seem to work
image

script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
--(assuming you have something in the player, a leaderstat for this script, of their coins / money value)
local money = player.leaderstats.Coins
money.Value += 5 -- replace 5 with the amount of money you want to give
end)

I didnt try to put that one code u did, I don’t really understand where im supposed to be placing it.

in a script inside the part you want to give money