Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

PlayerScripts not in test server?

Asked by
funyun 958 Moderation Voter
9 years ago

I tried making a hopperbin that lets you take control of other people's movement. It works for NPCs, but when I used it on another player in the test server, it couldn't disable the target player's ControlScript. Apparently the PlayerScripts folder isn't a member of the players in the server, but it is in simulation testing. How can I work around this to disable the target player's controls?

Keep in mind that I'm going to add more to this bin after I find a workaround for the controls problem. It's not quite done yet.

player = game.Players.LocalPlayer
mode = "Target"
camera = workspace.CurrentCamera
local target

tools = {}

function IsCharacter(model)
    if not model:IsA("Model") then return false end

    local bodyparts = "Head, Torso, Left Arm, Right Arm, Left Leg, Right Leg, Humanoid"
    local parts = 0

    for _, child in pairs(model:GetChildren()) do
        if string.find(bodyparts, child.Name) then parts = parts + 1 end
    end

    if parts == 7 then return true
    else return false
    end

end

function onButton1Down(mouse)
    if mode == "Target" then
        local valid = (IsCharacter(mouse.Target.Parent) and mouse.Target.Parent.Humanoid.Health > 0)
        local player = game.Players:GetPlayerFromCharacter(mouse.Target.Parent)

        if valid then
            target = mouse.Target.Parent

            if player then

                target.Humanoid.Name = "ResetDisabled" --Changing humanoid name disables Roblox built-in character reset
                player.PlayerScripts.ControlScript.Disabled = true

                for _, tool in pairs(player.Backpack:GetChildren()) do
                    table.insert(tools, tool)
                    tool.Parent = nil
                end

            end

            mode = "Control"
        end

    ----------

    elseif mode == "Control" then
        target.Humanoid.WalkToPoint = mouse.Hit.p
    end
end


function onSelected(mouse)
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end


script.Parent.Selected:connect(onSelected)
0
Is this a localscript? BinaryResolved 215 — 9y
0
Yup funyun 958 — 9y
1
Roblox has been enabling and disabling PlayerScripts quite a bit as they fix a few bugs with it so you may have tested your script while they were disabled. FearMeIAmLag 1161 — 9y

Answer this question