Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When a human toiches this model, it should move but its not?

This is a normal script inside my model It doesn't work though!

function onTouched(hit)


local check = hit.Parent:FindFirstChild("Humanoid")
if check ~= nil then
	local user = game.Players:GetPlayerFromCharacter(hit.Parent)
	game.Workspace.Model:MoveTo(Vector3.new(0,0,0))
end 

1 comment

0

Do you ever call the function?

1 answer

✓ Accepted answer

Touched events can only be done by parts not entire models. You can make a transparent brick with no collision and place it over the entire model. I rewrote some code for you. Just take note of where I've placed the trigger, just being a direct child of the model.

local touchtrigger = script.Parent.TouchPart --You can rename touchtrigger and TouchPart anything, just point it to the correct area. --
-- touchtrigger is the invisible brick that will activate the model to move when touched. --
function onTouched(hit)  
	    script.Parent:MoveTo(Vector3.new(0,0,0))  -- I decided to use a script.Parent, that way you don't need to keep track of names.--
	end

touchtrigger.Touched:connect(onTouched) -- If you change "touchtrigger" at the top, you need to change it here too. --

2 comments

0

Are you able to move a model with :MoveTo even when you don't have a PrimaryPart set? XD I forgot

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.