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
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
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)
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
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