What im trying to achieve here is when you press a key bind, a fire trail will clone into workspace wherever your mouse goes. But it stays in one place and does not move with the mouse. Can anyone help?
local ReplicatedS = game:GetService("ReplicatedStorage") local PainEvent = ReplicatedS:WaitForChild("firetrail") local ts = game:GetService("TweenService") PainEvent.OnServerEvent:Connect(function(player, mouse) local players = game.Players local player = players.LocalPlayer local victim = mouse.Parent:FindFirstChild("Humanoid") local victimCharacter = mouse.Parent local pained = victimCharacter:FindFirstChild("Pained") local h = victimCharacter:findFirstChild("Humanoid") local Player = victimCharacter local Char = victimCharacter local victimplayer = game.Players:GetPlayerFromCharacter(victimCharacter) local timeRemaining = 10 local bonniefire = game.ServerScriptService.GameFolder.Spells.CharacterSpells.Bonnie.firetrail.firetrailpart while timeRemaining > 0 do print("Seconds remaining: " .. timeRemaining) wait(0.1) timeRemaining = timeRemaining - 1 local firetrail = bonniefire:Clone() firetrail.Parent = game.Workspace firetrail.Position = mouse.Hit.Position --firetrail:Destroy() end wait(11) local fires = game.Workspace:FindFirstChild("FireTrail") fires:Destroy() end)
(Real Quick, from looking at the code, it seems as if you are new to ROBLOX scripting. If so, then I'd recommend you look at the official API for help when it comes to some of the code below.)
":GetMouse()" can only be called from local scripts, not server/module scripts. You'd want to pass in the mouses position as an argument and use that instead. It would look something like this: (game.Players.LocalPlayer can't be called from a server script aswell, but RemoteEvent's automatically pass the player who fired it to the server! You can also get the player the mouse is over by passing in the mouse's target. Real quick aswell, what is the point of the "Player" and "Char" variables you put in? They both have the same value which is already a variable.)
local ReplicatedS = game:GetService("ReplicatedStorage") local PainEvent = ReplicatedS:WaitForChild("firetrail") local ts = game:GetService("TweenService") PainEvent.OnServerEvent:Connect(function(player, mouse, position, target) local humanoid = target:FindFirstChild("Humanoid") if humanoid then local victim = humanoid.Parent end local pained = victim:FindFirstChild("Pained") local h = victim:findFirstChild("Humanoid") local victimplayer = game.Players:GetPlayerFromCharacter(victim) local timeRemaining = 10 local bonniefire = game.ServerScriptService.GameFolder.Spells.CharacterSpells.Bonnie.firetrail.firetrailpart while timeRemaining > 0 do print("Seconds remaining: " .. timeRemaining) wait(0.1) timeRemaining = timeRemaining - 1 local firetrail = bonniefire:Clone() firetrail.Parent = game.Workspace firetrail.Position = position --firetrail:Destroy() end wait(11) local fires = game.Workspace:FindFirstChild("FireTrail") fires:Destroy() end)