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

Is there a way to use local script stuff for a server script?

Asked by 6 years ago

I'm trying to do a 2x XP thing, But I cant use MarketPlaceService because I always get an error when I try to use it so I started using GamePassService but now I cant get the mouse of the player... The reason I need the mouse is because of the keybind so I'm kinda stuck? can anyone help me out??

This is what I'm working with:

local MP = game:GetService("GamePassService")
local mouse = Player:GetMouse()


mouse.KeyDown:Connect(function(key)
    local Train = math.random(1,3)
    if key == "t" then
        if db == false then 
        db = true
        --your code
0
No. Learn to use RemoteEvents and RemoteFunctions. XAXA 1569 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

If you need communication between server and client, you would use RemoteEvent or RemoteFunction.

Also, using the mouse for keybind is deprecated. It's recommended to use UserInputService instead.

userinput = game:GetService("UserInputService")

function keybind(keypressed, gameProcessedEvent)
    if keypressed.KeyCode == Enum.KeyCode.T then
        print("T was pressed")
        --etc
    end
end

userinput.InputBegan:connect(keybind)

Like mouse keybinds this script has to be a local script.

Ad

Answer this question