Hello devforum.
I made a door script using a tutorial on the devforum and when I test it, I get this error :
Infinite yield possible on ‘Workspace.Raven_fortnite3:WaitForChild(“HunanoidRootPart”)’
I tried searching on devforum for someone that had the same issue and it didn’t work.
-- SERVICES --
local uis, cas = game:GetService("UserInputService"), game:GetService("ContextActionService")
local cs, ts = game:GetService("CollectionService"), game:GetService("TweenService")
-- PLAYER & GUI VARIABLES --
local character = script.Parent
local players = game:GetService("Players")
local client = players.LocalPlayer
local root = character:WaitForChild("HunanoidRootPart")
local clientGui = client:WaitForChild("PlayerGui")
local doorGui = client:WaitForChild("doorKick")
local box = doorGui:WaitForChild("box")
local button = box:WaitForChild("button")
local fill = box:WaitForChild("fill")
local kickEvent = game.ReplicatedStorage:WaitForChild("onKick")
local mouse = client:GetMouse()
-- TWEENS --
local ti = TweenInfo.new(12, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
local fillTween = ts:Create(fill, ti,{Position = UDim2.new(0.5, 0, 0.5, 0)})
local door
-- UserInputService --
uis.InputBegan:Connect(function(inp, gpe)
if gpe then
return
end
if (inp.KeyCode == Enum.KeyCode[button.Text]) then
door = mouse.Target
if not (door ~= nil) then return end
if ((root.Position - door.Position).Magnitude > doorGui.MaxDistance) then return end
if (cs:HasTag(door, "Door")) then
print("Instance is a door")
fillTween:Play()
end
end
end)
I would appreciate any help. Thanks