-
What do you want to achieve? a script that pushes people back in the player’s vicinity (the whole script is done but there’s an issue on line 35
-
What is the issue? the error says
ServerScriptService.Deleatur:35: attempt to index nil with 'IsA'the second time, but it was able to read it the first time. -
What solutions have you tried so far? none, this is confusing.
here’s my script
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://7883741018"
game.Players.PlayerAdded:Connect(function(Player)
local debounce = false
Player.CharacterAdded:Connect(function(Character)
local Humanoid = Character:WaitForChild("Humanoid")
Player.Chatted:Connect(function(msg)
local spell = string.lower(msg)
if spell == "deleatur" and not debounce then
local practitioner = Character:FindFirstChild("Practitioner")
if practitioner.Value == true then
local magic = Character:FindFirstChild("Magic")
if magic.Value > 50 then
print("enough magic")
debounce = true
local Anim = Character:WaitForChild("Humanoid"):LoadAnimation(Animation)
Anim:Play()
wait(0.1)
local check = Instance.new("Part")
check.Shape = Enum.PartType.Cylinder
check.Orientation = Vector3.new(0,0,90)
check.Position = Character.HumanoidRootPart.Position
check.Size = Vector3.new(6.63, 21.664, 21.664)
check.Anchored = true
check.CanCollide = false
check.Name = Character.Name.."'s check part"
check.Transparency = 1
check.Parent = workspace
print("made part")
check.Touched:Connect(function(target)
if target.Parent:IsA("Model") then -- the part that errors if target.Parent.Name == Character.Name then return end
local cf = CFrame.lookAt(target.Parent.HumanoidRootPart.Position, Character.HumanoidRootPart.Position)
target.Parent.HumanoidRootPart.CFrame = cf
target.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
for index, joint in pairs(target:GetDescendants()) do
if joint:IsA("Motor6D") then
local socket = Instance.new("BallSocketConstraint")
local a1 = Instance.new("Attachment")
local a2 = Instance.new("Attachment")
a1.Parent = joint.Part0
a2.Parent = joint.Part1
socket.Parent = joint.Parent
socket.Attachment0 = a1
socket.Attachment1 = a2
a1.CFrame = joint.C0
a2.CFrame = joint.C1
socket.LimitsEnabled = true
socket.TwistLimitsEnabled = true
joint.Enabled = false
task.wait(0.3)
joint.Enabled = true
end
end
local bv = Instance.new("BodyVelocity")
bv.Velocity = target.Parent.HumanoidRootPart.CFrame.LookVector * -50
bv.Parent = target
wait(0.3)
bv:Destroy()
target.Parent.Humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end
end)
wait(0.2)
check:Destroy()
end
end
end
wait(5)
debounce = false
print("can work now")
end)
end)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.