So I have this script that i want to check if the players name is the name of the “ownername” value, and its not working? Any help?
local accepted = script.OwnerName
function check(p)
if p.Character.Name(accepted) then return true end
return false
end
script.Parent.ChildAdded:connect(function(child)
if child:IsA("Weld") then
if child.Part1 ~= nil then
if child.Part1.Parent ~= nil then
if game.Players:playerFromCharacter(child.Part1.Parent) ~= nil then
local player = game.Players:playerFromCharacter(child.Part1.Parent)
if check(player) then else child.Part1.Parent:BreakJoints() end
end
end
end
end
end)
You aren’t indexing the Value property of OwnerName, meaning it will always return false because you’re trying to compare an Instance and a string.
You’re attempting to call Name instead of indexing it as a property, that’ll throw an error.
I’ve tidied up your script a little, this should work if my guesses towards what you’re doing is correct.
function check(p)
return p.Name==script.OwnerName.Value
end
script.Parent.ChildAdded:connect(function(child)
if child:IsA("Weld") then
if child.Part1~=nil and child.Part1.Parent~=nil then
local player=game.Players:GetPlayerFromCharacter(child.Part1.Parent)
if player and not check(player) then
player.Character:BreakJoints()
end
end
end
end)