Minigames script won't work

Hello, I am a scripter an I have been using some tutorials, as I am fairly new. I have only been working with lua for 2-3 years. If you can please explain to me why this script won’t work (I have looked over, my spelling and where the places are is right) and if possible, could you fix it?

	if hit~= nil then
		if hit.Parent~= nil then
			if hit.Parent.Humanoid.Health~= 0 then
				local player = game.Players:GetPlayerFromCharacter(hit.Parent)
				player.Settings.Win.Value = true
				local spawns = game.Workspace.Spawns:GetChildren()
				hit.Parent.HumanoidRootPart.CFrame = spawns[math.random(1,#spawns)].CFrame +,3,0)

I’m pretty sure this is where the error lies. You’re doing math operations with 2 different values, which throws an error. You should do:

hit.Parent.HumanoidRootPart.CFrame = spawns[math.random(1,#spawns)].CFrame *,3,0)

Ok, thank you for the tip! I will tell you if it works!

It worked! Thank you so much! 30chars

1 Like