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

Whats an alternative to get the players mouse?

Asked by
Prioxis 673 Moderation Voter
10 years ago

I'm making an admin script but I need to press Z in order for it to work Just because I want to avoid message commands

but

local Mouse = game.Players.LocalPlayer:GetMouse()

only works in a localscript and my admin doesn't work as a local script anymore

so can someone either tell me how my script can work in a local without messing up the functions of my script?

Here's my script :

--Commands

--chat commands--
--Green
--Red
--Yellow
--Blue

--key commands--
--z    

local Admins = {"YouShalllNotPass", "Player", "Player1",  "Ray5069", "TacitaVolpes", "Wildfighter812", "LisforLucas"}
function IsAdmin(PlayerInstance)
 local PlayerName = PlayerInstance.Name:lower()
 for i = 1, #Admins do
  local AdminName = Admins[i]:lower()
  if AdminName == PlayerName then
   return true
  end
 end
 return false
end
game.Players.PlayerAdded:connect(function(NewPlayer)
repeat wait() until NewPlayer.Character

local Mouse = game.Players.LocalPlayer:GetMouse()

 if IsAdmin(NewPlayer) then
print'Ventivian Commands have been hooked into the system'

local s1 = Instance.new("SelectionBox", NewPlayer.Character.Head)
    s1.Adornee = s1.Parent
    s1.Color = BrickColor.new("Medium stone grey")
    s1.Transparency = 0.5

local s2 = Instance.new("SelectionBox", NewPlayer.Character:FindFirstChild("Right Leg"))
        s2.Adornee = s2.Parent
            s2.Color = BrickColor.new("Medium stone grey")
                s2.Transparency = 0.5

local o = Instance.new("SelectionBox", NewPlayer.Character:FindFirstChild("Left Leg"))
        o.Adornee = o.Parent
            o.Color = BrickColor.new("Medium stone grey")
                o.Transparency = 0.5

local  s4 = Instance.new("SelectionBox", NewPlayer.Character:FindFirstChild("Right Arm"))
        s4.Adornee = s4.Parent
            s4.Color = BrickColor.new("Medium stone grey")
                s4.Transparency = 0.5

local  s5 = Instance.new("SelectionBox", NewPlayer.Character:FindFirstChild("Left Arm"))
        s5.Color = BrickColor.new("Medium stone grey")
            s5.Transparency = 0.5
        s5.Adornee = s5.Parent

        local h = Instance.new("StringValue", game.Workspace)
        h.Value = ""
        h.Name = "Kicked"

    Mouse.KeyDown:connect(function(key)
        if key == "z" then

            if NewPlayer.PlayerGui:FindFirstChild("ScreenGui") then
                NewPlayer.PlayerGui.ScreenGui:Destroy()
            else
        local b = Instance.new("ScreenGui", NewPlayer.PlayerGui)

        local x = Instance.new("Frame", b)
        x.Name = "Menu"
        x.BackgroundColor3 = Color3.new(0, 255, 0)
        x.BackgroundTransparency = 0.5
        x.Size = UDim2.new(.15, 0, .5, 0)
        x.Position = UDim2.new(0, 10, 0, 10)

        local c = Instance.new("TextButton", x)
        c.Position = UDim2.new(.25, 0, .5, 0)
        c.BackgroundTransparency = 0
        c.BackgroundColor3 = Color3.new(0, 0, 0) 
        c.Size = UDim2.new(0, 100, 0, 25)
        c.TextColor3 = Color3.new(0, 255, 0)
        c.Style = 3
        c.Text = "Kick"

        local v = Instance.new("TextBox", x)
        v.Size = UDim2.new(0, 100, 0, 50)
        v.Position = UDim2.new(.25, 0, .25, 0)
        v.Name = "TextBox"

        local n = Instance.new("Frame", b)
        n.Name = "Menu2"
        n.BackgroundColor3 = Color3.new(0, 255, 0)
        n.BackgroundTransparency = 0.5
        n.Size = UDim2.new(.15, 0, .5, 0)
        n.Position = UDim2.new(.2, 0, 0, 10)

        local a = Instance.new("TextButton", n)
        a.Position = UDim2.new(.25, 0, .5, 0)
        a.BackgroundTransparency = 0
        a.BackgroundColor3 = Color3.new(0, 0, 0) 
        a.Size = UDim2.new(0, 100, 0, 50)
        a.TextColor3 = Color3.new(0, 255, 0)
        a.Style = 3
        a.Text = "GodMode"
        a.Font = "SourceSansBold"
        a.FontSize = "Size24"

        local a1 = Instance.new("TextBox", n)
        a1.Position = UDim2.new(.25, 0, .30, 0)
        a1.Size = UDim2.new(0, 100, 0, 50)

        local a2 = Instance.new("TextButton", n)
        a2.Position = UDim2.new(.25, 0, .1, 0)
        a2.BackgroundTransparency = 0
        a2.BackgroundColor3 = Color3.new(0, 0, 0) 
        a2.Size = UDim2.new(0, 100, 0, 50)
        a2.TextColor3 = Color3.new(0, 255, 0)
        a2.Style = 3
        a2.Text = "Change Fog"
        a2.Font = "SourceSansBold"
        a2.FontSize = "Size12"

        local n1 = Instance.new("Frame", b)
        n1.Name = "Menu3"
        n1.BackgroundColor3 = Color3.new(0, 255, 0)
        n1.BackgroundTransparency = 0.5
        n1.Size = UDim2.new(.15, 0, .5, 0)
        n1.Position = UDim2.new(.4, 0, 0, 10)

        local n2 = Instance.new("TextBox", n1)
        n2.Position = UDim2.new(.25, 0, .30, 0)
        n2.Size = UDim2.new(0, 100, 0, 50)  

        local c1 = Instance.new("TextButton", n1)
        c1.Position = UDim2.new(.25, 0, .5, 0)
        c1.BackgroundTransparency = 0
        c1.BackgroundColor3 = Color3.new(0, 0, 0) 
        c1.Size = UDim2.new(0, 100, 0, 25)
        c1.TextColor3 = Color3.new(0, 255, 0)
        c1.Style = 3
        c1.Text = "Change WalkSpeed"

        --button scripts

        a.MouseButton1Down:connect(function(click2)
            if NewPlayer.Character.Humanoid.MaxHealth == math.huge then
                NewPlayer.Character.Humanoid.MaxHealth = 100 
            else
                NewPlayer.Character.Humanoid.MaxHealth = math.huge
                end
            end)

        c.MouseButton1Down:connect(function(click)
            game.Workspace.Kicked.Value = NewPlayer.PlayerGui.ScreenGui.Menu.TextBox.Text

    local o1 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Left Leg"))
        o1.Adornee = o1.Parent
        o1.Color = BrickColor.new("Medium stone grey")
        o1.Transparency = 0.5

        local o2 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Left Arm"))
        o2.Adornee = o2.Parent
        o2.Color = BrickColor.new("Medium stone grey")
        o2.Transparency = 0.5

        local o3 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Right Arm"))
        o3.Adornee = o3.Parent
        o3.Color = BrickColor.new("Medium stone grey")
        o3.Transparency = 0.5

            local o4 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Right Leg"))
        o4.Adornee = o4.Parent
        o4.Color = BrickColor.new("Medium stone grey")
        o4.Transparency = 0.5

        local o5 = Instance.new("SelectionBox", game.Workspace:FindFirstChild(game.Workspace.Kicked.Value):FindFirstChild("Torso"))
        o5.Adornee = o5.Parent
        o5.Color = BrickColor.new("Medium stone grey")
        o5.Transparency = 0.5
        wait(1)
        game.Players:FindFirstChild(game.Workspace.Kicked.Value):Kick()
        end)

            a2.MouseButton1Down:connect(function(click3)
            game.Lighting.FogEnd = a1.Text
            end)

            c1.MouseButton1Down:connect(function(click4)
            NewPlayer.Character.Humanoid.WalkSpeed = n2.Text
            end)


NewPlayer.Chatted:connect(function(message)
if message == "Blue" then
s1.Color = BrickColor.new("Bright blue")
s2.Color = BrickColor.new("Bright blue")
o.Color = BrickColor.new("Bright blue")
s4.Color = BrickColor.new("Bright blue")
s5.Color = BrickColor.new("Bright blue")    
    end
end)

NewPlayer.Chatted:connect(function(message)
if message == "Red" then
s1.Color = BrickColor.new("Bright red")
s2.Color = BrickColor.new("Bright red")
o.Color = BrickColor.new("Bright red")
s4.Color = BrickColor.new("Bright red")
s5.Color = BrickColor.new("Bright red")
    end
end)

NewPlayer.Chatted:connect(function(message)
if message == "Green" then
s1.Color = BrickColor.new("Bright green")
s2.Color = BrickColor.new("Bright green")
o.Color = BrickColor.new("Bright green")
s4.Color = BrickColor.new("Bright green")
s5.Color = BrickColor.new("Bright green")
    end
end)

NewPlayer.Chatted:connect(function(message)
if message == "Yellow" then
s1.Color = BrickColor.new("Bright yellow")
s2.Color = BrickColor.new("Bright yellow")
o.Color = BrickColor.new("Bright yellow")
s4.Color = BrickColor.new("Bright yellow")
s5.Color = BrickColor.new("Bright yellow")
    end
end)

                end
            end
        end)
    end
end)





1
Use RemoteFunctions or RemoteEvents to pass data between scripts. Perci1 4988 — 10y
0
You could have something that tells a localscript to tell the mouse to do something. Thats just an idea though. Teeter11 281 — 10y

1 answer

Log in to vote
-3
Answered by 10 years ago

Put a script within the admin script, it must be disabled, but, it will say this:

local mouse = game.Players.LocalPlayer:GetMouse()
-- your part of the code here --

This would be your script:

local getscript = script.LocalScript:Clone()
getscript.Parent = AdminName
getscript.Disabled = false
1
GetMouse() must be used in a LocalScript in order to work right. Perci1 4988 — 10y
0
Ok, I edited it. deputychicken 226 — 10y
0
No, you'd use RemoteFunctions/Events. Tkdriverx 514 — 10y
Ad

Answer this question