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

Attempt to index local 'mouse' (a nil value)???

Asked by 5 years ago

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)

0
You can't get the mouse from a server-sided script Rare_tendo 3000 — 5y

2 answers

Log in to vote
0
Answered by
xdeno 187
5 years ago

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

0
Oh thank you i didn't know you chould push a value(mouse) through fire server, thanks! tonije123 9 — 5y
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? tonije123 9 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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?

0
No, the answerer already helped you on one part. Don't make them make your full code. User#19524 175 — 5y

Answer this question