This server script is activated when clicked. When clicked, it will spawn a new part and have a localscript inside of it. But the localscript doesn't work?
When i look at the workspace the localscript is there inside the part, but it doesnt work.
Server Script:
part = script.Parent part.ClickDetector.MouseClick:Connect(function(player) repeat wait() until player.Character local newpart = Instance.new("Part",workspace) newpart.Size = Vector3.new(3,3,3) newpart.CFrame = player.Character.HumanoidRootPart.CFrame * CFrame.new(0,4,0) newpart.Touched:Connect(function(hit) local Reward = script.Reward:Clone() if hit then Reward.Parent = newpart Reward.Disabled = false wait(0.1) Reward:Destroy() end end) end)
Local Script:
local player = game.Players.LocalPlayer local part = script.Parent part.Touched:Connect(function(hit) local char = hit.Parent local humanoid = char:WaitForChild("Humanoid") print("Touched!") end)
Your variable should be:
local humanoid = char:FindFirstChild("Humanoid")
Since that is how Humanoid is located, that will make your script work now.