Hello there, i have a problem with cloning. Before, this script worked, but then it is not working at all. I tried to set CanCollide and Anchored to true in the script, but no result. Clone is not even appearing in Folder or Workspace, no errors in output. Any help will be appreciated
local rs = game.ReplicatedStorage
local eventFolder = rs:WaitForChild("Events")
local valueToGive = 1
local PlayerDataHandler = require(game.ServerScriptService:WaitForChild("PlayerDataHandler"))
eventFolder.SpawnCash.OnClientEvent:Connect(function()
local cash = rs.cash:Clone()
local cubeposition = workspace.cube.PrimaryPart.Position
local cashPosition = cubeposition + Vector3.new(0, 3, 0)
cash.Position = cashPosition
cash.Parent = workspace:WaitForChild("CashFolder")
cash.CanTouch = true
cash.CanCollide = true
cash.Touched:Connect(function(hit)
if hit.Parent:FindFirstChildOfClass("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
PlayerDataHandler:Update(player, "Cash", function(currentCash)
return currentCash + valueToGive
end)
end
end
end)
end)
That would make it more complicated, you dont need to do that. Parenting works fine, just keep it with chasfolder
Can you print out print(cash) to make sure it is not nil?
Another thing besides the problem that you have is that this code has been placed inside the LocalScript, but you are trying to access the ServerScriptService which is only accessible for the server only. I believe it will show some kind of error. If you really want to use that module both on server-side and client-side, please do consider ReplicatedStorage where both clients and servers have access to it.