Hi, So me and my friend are trying to make a marble game but we need help with one of the scripts. We have the script so when we click a button the marble spawns, then when you touch it, it puts you in the marble. We want to make it so only one person can get inside the marble at one time.
Here is the script we are using for the marble:
function touch(hit)
local h = hit.Parent:FindFirstChild("Humanoid")
if h then
local stuff = hit.Parent:GetChildren()
for i = 1,#stuff do
if stuff[i].ClassName == "Hat" then
stuff[i]:Destroy()
end
end
game.Players:FindFirstChild(hit.Parent.Name).Character.UpperTorso.CFrame = script.Parent.CFrame + Vector3.new(0,.5,0)
script.Parent.Parent = hit.Parent
local w = Instance.new("Weld")
w.Part0 = hit.Parent.UpperTorso
w.Part1 = script.Parent
w.Parent = hit.Parent.UpperTorso
script.Parent.Anchored = false
while true do
wait()
h.Sit = true
end
end
end
script.Parent.Touched:connect(touch)
And here is the issue demonstrating our issue:
We are also having an issue where if two marbles touch the turn into 1 making both players in one marble.