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

attempt to index mouse ( a nil value )???

Asked by 6 years ago

Is there anything wrong about it?

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player,damage)
    local anim = Instance.new("StringValue")
    anim.Name = "toolanim"
    anim.Value = "Slash"
    anim.Parent = script.Parent
    local play = player.Name
    print(play)
    mouse = player:GetMouse()
    if mouse.Target.Configuration.Axe.Value == true then
    local thing = mouse.Target
    thing.Configuration.HP.Value = thing.Configuration.HP.Value - damage
    game.ReplicatedStorage.RE.MM:FireServer(thing.Configuration.NAM,thing.Configuration.HP,thing.Configuration.MHP)
    elseif mouse.Target == nil then 
end
end)
0
is this a LocalScript or a normal script? UgOsMiLy 1074 — 6y
0
Try local mouse = player:GetMouse() instead. User#21242 20 — 6y
0
its a script, but imusing it in a ls Thescrubbyman 2 — 6y
0
tried local mouse, didn't work. Thescrubbyman 2 — 6y

1 answer

Log in to vote
0
Answered by
Nikkulaos 229 Moderation Voter
6 years ago

The thing you did wrong is trying to get the players mouse through a server script. Its only accessible in a local script.

You would need to go back to your server script where you fired the event, and add the mouses target through the :FireServer() event.

Example:

Local:

local mouse = player:GetMouse()
local damage = 10
local target = mouse.Target
event:FireServer(damage, target)

Server:

script.Parent.RemoteEvent.OnServerEvent:Connect(function(player,damage, target)
    local anim = Instance.new("StringValue")
    anim.Name = "toolanim"
    anim.Value = "Slash"
    anim.Parent = script.Parent
    local play = player.Name
    print(play)
    if target.Configuration.Axe.Value == true then
    local thing = target
    thing.Configuration.HP.Value = thing.Configuration.HP.Value - damage
    game.ReplicatedStorage.RE.MM:FireServer(thing.Configuration.NAM,thing.Configuration.HP,thing.Configuration.MHP)
    elseif target == nil then 
end
end)

(Im not 100% sure this will work, so if u have any problems please comment.)

Ad

Answer this question