Touched not working

So I made a script that is somehow not working, It’s supposed to be deleted and should also give money once touched, but neither of those are happening. And also no errors at all. Thank you for reading!

script.Parent.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	if plr then
		plr.leaderstats.Money.Value += game.ReplicatedStorage.Players:FindFirstChild(plr.Name).Chad.MoneyClick.Value
		script.Parent:Destroy()
	end
end)

Edit: I originally made another script inside a local script that cloned it, I changed it into a remote event script, now it’s getting deleted but it doesn’t give any money! Also it doesn’t print any errors

You can trie this

local part = workspace.Part --path part

part.Touched:Connect(function()
    local t = part:GetTouchingParts()
    for i, v in pairs(t) do
        if game.Players:GetPlayerFromCharacter(v.Parent) then
            local plr = game.Players:GetPlayerFromCharacter(v.Parent) 
            plr.leaderstats.Money.Value +=game.ReplicatedStorage.Players:FindFirstChild(plr.Name).Chad.MoneyClick.Value
           part:Destroy()
        end
    end
end

is the canTouch property on?
is script.Parent actually is a part
did you try printing something to see if something did touch?

This does somehow not work, no errors too. But I should note this, with that variable you made called “Part” won’t work cause I made it so that whenever you click a specific part it would drop money parts, and whenever you touch that it would give you money, so that variable won’t work cause of the fact that there are many more parts called Money inside workspace.

Yes it’s on, yes it’s inside a part and no I haven’t printed anything lol, lemme try that rq

Edit, I’ve tried it, this is the script

script.Parent.Touched:Connect(function(hit)
	local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
	print("Touched")
	if plr then
		print("Touched2")
		plr.leaderstats.Money.Value += game.ReplicatedStorage.Players:FindFirstChild(plr.Name).Chad.MoneyClick.Value
		print("Touched3")
		script.Parent:Destroy()
	end
end)

it prints all 3 but still doesn’t work

what doesnt work, be more specific please.

strange try adding the money through just a number instead of a value for now

like Money.Value += 10

You should maybe read their original post?

Well literally nothing about the script works and it doesn’t print any errors somehow

have you checked if the replicated storage value has sumthing in it? and see if “plr” actually prints the plr. and if “script.Parent:Destroy” doesn’t work then it means the code above is yielding it or similar.

pls does work, I’ve printed it and it worked, and also I originally had a local script that cloned it, I’ve changed that to a remote now it does get deleted, but it’s not giving any money at all, and also it doesn’t print any errors

I’ve changed it to a remote, now it works, it gets deleted but doesn’t give any money

you shouldnt allow the client to run a remote and give themselves money. that can be easily exploited. i suggest you switch to using a server script

also about the money make sure its a number value or int value not a string value (if its a string value do tonumber())

give the money on the server not the client

it is a number value, and I don’t really care about exploiters they do they

I don’t really understand this, I’ve already switched to a remote so it’s not client right? or am I stupid

plr.leaderstats.Money.Value += game.ReplicatedStorage.Players:FindFirstChild(plr.Name).Chad.MoneyClick.Value

you want to add the money on the server because then the money is only on the client not the server, if it is not on the server then you cant make a shop with it as the shop will be ran on the server

make the

plr.leaderstats.Money.Value += game.ReplicatedStorage.Players:FindFirstChild(plr.Name).Chad.MoneyClick.Value

in the server

You’ll need a remote to remove/add currency to yours. As if it were to be locally, it wouldn’t be shown to everyone and wouldn’t be good and buggy.

Ohh, no no this is inside a script, it’s not a local script