My door script isn’t working, I want it to open once a player reaches with in 5 studs of the door, he is my script:
local RP = script.Parent.PrimaryPart
local Radius = 5
local DetectionPart = script.Parent.Detectionpart
local TweenService = game:GetService("TweenService")
local DoorTween = TweenService:Create(RP, TweenInfo.new(0.5,Enum.EasingStyle.Bounce), {CFrame = RP.CFrame * CFrame.Angles(0,math.rad(90),0)})
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(plr)
local Character = plr.Character or plr.CharacterAdded:Wait()
local HRP = Character.HumanoidRootPart
if (HRP.Position - DetectionPart.Position).Magnitude <= Radius then
DoorTween:Play()
end
if DoorTween.Completed then
print("yes") --for some reason this thing prints first thing when I test it.
end
end)
So yeah, it isn’t working. I put a note on the final “if” statement that it prints yes when I test the game, so it is playing even though I’m not in the radius, but even weirder, its not even changing the position, it just stays in the same position, (I want it to tween 90 degress but it isn’t, even though its printing yes that it did). I tried to see if anyone has had this problem as well. No one to my knowledge
As you can see, It printed “yes” but it didn’t actually tween 90 degress + its not even suppose to be printing yes!
this is a picture when I get in the 5-stud range:
as you can see, Nothing happens. Its a script under the whole door model btw: