Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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)

4 comments

0

is this a LocalScript or a normal script?

0

Try local mouse = player:GetMouse() instead.

0

its a script, but imusing it in a ls

0

tried local mouse, didn't work.

1 answer

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.)

This discussion is preserved as it was. New answers, comments, and votes are closed.