Hello , I'm getting mad because I'm trying to do something but , I just don't know how to script ;-; , I thought that this script would have worked , welp it's working but like , I don't need to touch it that it will break :
function x(hit) script.Parent.Anchored = false script.Parent.GlassSound:Play() script:remove() end script.Parent.Touched:connect(x)
I'm asking for your help , I want that when somebody hit the block , it's unanchoring . Thanks ;-;
function x(hit) if hit.Parent and game:GetService("Players"):GetPlayerFromCharacter(hit.Parent) then script.Parent.GlassSound:Play() for i,v in pairs(script.Parent:GetChildren()) do if v:IsA("BasePart") then v.Anchored = false end end script:Destroy() end end for i,v in pairs(script.Parent:GetChildren()) do if v:IsA("BasePart") then v.Touched:Connect(x) end end
Line 2 will check to make sure it's actually a player that touched the table
Lines 5-8 will run through everything in the table model, if it's a part then it will unanchor it
And lines 15-16 runs through every part in the model, and line 17 waits for it to be touched
This should work:
script.Parent.Touched:Connect(function(hit) -- Make sure you use Connect instead of: -- connect if hit.Parent.Name == "Humanoid" then script.Parent.Anchored = false script.Parent.GlassSound:Play() else return hit end end)
So you saying that it's working but you don't need to touch the brick for it to be called? If so than the code above should solve you problem.