help pls but give me a little support because I bad at scripting
(this is what I want)
help pls but give me a little support because I bad at scripting
(this is what I want)
That is simple
Part1.Touched:Connect(function(hit)
If hit.Parent:IsA(“Model”) then
hit.Parent:SetPrimaryPartCFrame(part2.CFrame)
end
end)
They are talking about a specific model, so instead:
Part1.Touched:Connect(function(hit)
If hit.Parent == game.Workspace.part1 then
hit.Parent:SetPrimaryPartCFrame(part2.CFrame)
end
end)
probably a good idea to store part1 as a variable, but yea this should work
Part1.Touched:Connect(function(hit)
If hit.Parent:FindFirstChild(“beteleported”) then
hit.Parent:SetPrimaryPartCFrame(part2.CFrame)
end
end)
i think this should be better, it allows you to add more models to be teleported in an easy way
it isn’t working do you know what is going wrong? Am i supposed to put it in a specific place?
Part1
as a variable.if statement
needs to start with a low case if
, not If
.''beteleported''
with"beteleported"
.Part2
as a variable.Uh so I don’t know really how to define a variable in Lua can you teach me how?..
local Part1 = ..path.to.Part.
local Part2 = ..path.to.Part.
Replace ..path.to.Part.
with the location of those parts. Example:
local Part1 = workspace:FindFirstChild("Part1")
yea u still didn’t change the If to an if : P
Oh yeah i forgot, but still the script is going poof any clue where it went?
I dont know where exactly server script services puts scripts to, but it isn’t a problem, the script should still run fine (if it doesn’t, did you indent the hit.Parent:SetPrimaryPart line?)
I did
oh wait ima try defining “beteleported”
Put this in the script 'beteleported'
in line 5
replace line 5 with if hit.Parent == script.Parent
Like this?
Yes
instead of using :SetPrimaryPartCFrame() I recommend using :PivotTo() instead as it does the same thing but with better performance
So with your code it would look like:
local Part1 = workspace:WaitForChild("Part1")
local Part2 = workspace:WaitForChild("Part2")
Part1.Touched:Connect(function(hit)
if hit.Name == "beteleported" then
-- no need to grab the parent since the part touching it is all we need
hit:PivotTo(Part2.CFrame)
end
end)
bro you didn’t, indend like 6 : P