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 local 'mouse' (a nil value)???

So after i converted my local script and moved it to a normal script witch acts as a remote event for it(swiching game from non-fe to fe) I started getting this message:attempt to index local 'mouse' (a nil value) I don't know what is wrong. I whould apreciate if someone could look at the code and figure it out. Thanks in advance

script.Fire.OnServerEvent:Connect(function(Player)

local mouse = Player:GetMouse() local flame = game.Workspace.Amaterasu local db = false

local timeout = 20

db = true
while timeout > 0 do
local  flameCOPY = flame:Clone()
flameCOPY.Parent = game.Workspace
flameCOPY.CFrame = mouse.Hit
flameCOPY.Name = "Amaterasu2"

	timeout = timeout - 1
	wait(0.1)
 end
timeout = 20

end)

1 comment

0

You can't get the mouse from a server-sided script

2 answers

You cannot access the mouse from a server script so you need to split it into a local and server script.

In the local script you want to tell the server your mouse position, something like so:

local player = game:GetService("Players").LocalPlayer
local mouse = local Mouse = player:GetMouse()

yourFunction()
local firePosition =  mouse.Hit
Fire:FireServer(firePosition )
end

And in the server script you do the rest of the script

local player = game:GetService("Players").LocalPlayer
local mouse = local Mouse = player:GetMouse()

script.Fire.OnServerEvent:Connect(function(Player, firePosition)
local flame = game.Workspace.Amaterasu 
local db = false
local timeout = 20
db = true
while timeout > 0 do
local  flameCOPY = flame:Clone()
flameCOPY.Parent = game.Workspace
flameCOPY.CFrame = firePosition 
flameCOPY.Name = "Amaterasu2"

    timeout = timeout - 1
    wait(0.1)
 end
timeout = 20
end)

You should look at this wiki article for more info, there's a lot to learn about switching to F.E.

https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

2 comments

0

Oh thank you i didn't know you chould push a value(mouse) through fire server, thanks!

0

Thanks for that buti have one more question, in order for my script to work i need a "continous" mouse position update. The move is rapidly spawned where the user is moving their mouse. Any help on that?

Thanks for that buti have one more question, in order for my script to work i need a "continous" mouse position update. The move is rapidly spawned where the user is moving their mouse. Any help on that?

1 comment

0

No, the answerer already helped you on one part. Don't make them make your full code.

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