I have a script that checks for a player touching another player, and at the end of the script, it checks for a changed value. The first half works just fine, but the second half where it starts checking for a changed value isn't working.
local grabblock = script.Parent.Torso local vampchar = script.Parent grabblock.Touched:Connect(function(grabbedchar) if grabbedchar.Parent:FindFirstChild("Humanoid") then if vampchar.BeastMode.Value == true and grabbedchar.Parent.Role.Value ~= "Vampire" then vampchar.Grabbing.Value = true vampchar.GrabbingWho.Value = grabbedchar.Parent.Name grabbedchar.Parent.Grabbed.Value = true grabbedchar.Parent.GrabbedBy.Value = vampchar.Name local moveto = game.ServerStorage.GrabWeld:Clone() moveto.Parent = grabbedchar.Parent moveto.Attachment0 = grabbedchar.Parent.Torso.GrabAttatch moveto.Attachment1 = vampchar.Torso.GrabAttatch end end vampchar.BeastMode.Changed:Connect(function() if vampchar.BeastMode.Value == false then vampchar.Grabbing.Value = false vampchar.GrabbingWho.Value = "" grabbedchar.Parent.Grabbed.Value = false grabbedchar.Parent.GrabbedBy.Value = "" end end) end)
grabbedchar.Parent is supposed to be the character that touched the other character, but on the second half, it starts looking at the character's accesories.
The problem is at line 16, you’re doing grabbedchar.Parent.BeastMode without checking if whatever touched it is part of the character. Let me explain. - Handle of an accessory touched a part - It gets to the lower part of the script - Handle.Parent is an accessory - You’re not keeping all those values in an accessory.
A fix would be to check if those values exist.
local grabbed = grabbedchar.Parent:FindFirstChild(“Grabbed”) local grabbedBy = grabbedchar.Parent:FindFirstChild(“grabbedBy”) if not grabbed or grabbedBy then return end grabbed.Value = false grabbedBy.Value = “”