So I have this script that should be making the player jump if they arn’t the player named in the child boolvalue. Any help here?
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.Humanoid.Jump = true end
end
end
end
end
end)
I’m going to change up your script a lot to make it better
I’m going to assume that when you said boolvalue you actually meant string value since you said name, which should be a string
local PlayerService = game:GetService("Players") -- get playerservice
local OwnerName = script.OwnerName.Value -- define owner
script.Parent.Changed:Connect(function(newvalue) -- setup a function connected to the Changed event with a newvalue arg
if newvalue ~= "Occupant" then return end -- make sure the change was an occupant
local Player = PlayerService:GetPlayerFromCharacter(script.Parent.Occupant.Parent) -- get the player
if not Player then return end -- check if player is nil (maybe an npc sat down idk)
if Player.Name == OwnerName then -- check if its the owner
--rest of code here
else -- if it isn't
script.Parent.Occupant.Jump = true -- make them jump
end -- close if statement
end) -- close function
if you’re only checking for Occupant in that situation, then why not hook it to :GetPropertyChangedSignal(“Occupant”), that way you don’t get the un-necessary fires.