Hello, I am working on a fighting game, but my local script in a part thats in a cloned model will not print or do anything. I am trying to make a money collect script .Here is the script’s code:
print(“Script found”)
local Bill = script.Parent
local player = game.Players.LocalPlayer
Bill.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
player.leaderstats.money.Value = player.leaderstats.money.Value + 1
hit.Parent:Destroy()
end
end)
I have tried to look through dev forums, change the local script to a normal script. And change the location and model. But nothing has helped. The model is also cloned by a normal script, and the script seems to still appear when playing, but it won’t run. Does anybody know the solution?
because youre trying to get the localplayer in a serverscripts which they dont have
print("Script found")
local Bill = script.Parent
Bill.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
player.leaderstats.money.Value = player.leaderstats.money.Value + 1
hit.Parent:Destroy()
end
end)