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