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

How do i find a player's mouse a script instead of a local script?

Asked by
rexpex 45
7 years ago

I have this punching script and and for some reason it says "mouse(a nil value)" here is the script

local Humanoid = player.Character.Humanoid
    local debounce = false
    local mouse = player:GetMouse()
    mouse.KeyDown:connect(function(key)



        if key == "q" then
            if not debounce then
            debounce = true 
    ------------------------------------------------------------------------    
        --Animation for Punch
        local Punch = Instance.new("Animation")
        Punch.AnimationId = "http://www.roblox.com/Asset?ID=644505212"
        local animTrack = Humanoid:LoadAnimation(Punch) 

            animTrack:Play(0,2,2.5) 
-------------------------------------------------------------------------------     
        --Lighting for Punch

        local lightning = replicatedstorage.RicoClass:WaitForChild("Lightning")
        local light = lightning:clone()

        light.Parent = game.Workspace
        light.Anchored = false
        light.CanCollide = false
        local w = Instance.new("Weld" ,light)
        w.Part0 = player.Character.RTIndexFinger
        w.Part1 = light
        w.C1 = CFrame.Angles(0,0,40)
        w.C0 = CFrame.new(0,0,0.2)
light.Touched:connect(function(part)
    if not db then
        db = true
    local h = part.Parent:findFirstChild("Humanoid")
    if h ~= nil then
        h.Health = h.Health - 10
        wait(0.3)
        db = false
        end
    end
end)

        wait(0.3)
        light:Destroy()





------------------------------------------------------------------------------- 


wait(0.3)
debounce = false

    end
        end
        end)
1
You can't. OldPalHappy 1477 — 7y

1 answer

Log in to vote
0
Answered by
RubenKan 3615 Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

You cant. The server doesnt have a mouse. To acces mouse properties in the server you'll have to send each property over using remoteEvents fromout the client. (Or remoteFunctions)

Localscript:

Event:FireServer(mouse.Target,mouse.Hit)

Serverscript:

Event.OnServerEvent:Connect(function(player,target,hit)
--do stuff
end)
Ad

Answer this question