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

Help with converting a Local Script to FE?

With the new filtering enabled update, a lot of my scripts where broken and I'm trying to fix them all.

One tool I have is run completely by 1 Local Script. One part I'm working on now gave the player an aura (basically just welded an invisible particle emitting part to the character's torso) when a tool is equipped. This is how my LocalScript looked before.

plr =  game.Players.LocalPlayer
repeat wait() until plr.Character ~= nil
char = plr.Character
tool = script.Parent	
mouse = plr:GetMouse()
aura = tool.aura


function Equip()
stage = 1
aura.Anchored = false
	
	local weld = Instance.new("Weld")
	aura.CFrame = char.Torso.CFrame
	weld.Parent = aura
	weld.Name = "BackWeld"
	weld.Part0 = char.Torso
	weld.Part1 = aura
	
whirl()
aura.Constant:Play()

end

tool.Equipped:connect(Equip)

I know I need to use RemoteEvents but I'm still kind of confused about that. How can the regular script In ServerScriptStorage define Local Player and the other variables in the Local Script to be able to run my Equip() function? Do I have to change some of the coding in my functions or can I just call them from the regular script in ScriptServerStorage?

1 comment

0

Couldn't you just put the particle emitter on the torso?

1 answer

✓ Accepted answer

Okay I'm pretty new to FE and all too but I think I got it so:

With the Local Script you basically send the server a 'warning' to make your things happen and the Script is where you put everything into practice.So what you'd have to do is:

Local Script

tool = script.Parent
local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Aura") --I put the RemoteEvents in the ReplicatedStorage, name it whatever you want but make sure to change :WaitForChild("YourNameHere")

function Equip()

	RemoteEvent:FireServer(nil)--The Parameter is nil because I'm only passing the player(It automatically passes the player)

end


tool.Equipped:Connect(Equip)

Script

local RemoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("Aura")

RemoteEvent.OnServerEvent:Connect(function(player) --When it's Called
	aura.Anchored = false
   	local weld = Instance.new("Weld")
    	aura.CFrame = player.Character.Torso.CFrame
    	weld.Parent = aura
    	weld.Name = "BackWeld"
    	weld.Part0 = char.Torso
    	weld.Part1 = aura
end)

Hope this helped you.

5 comments

0

On the script, I get: attempt to index global 'aura' (a nil value) @brokenrares

0

My bad, forgot to include this:

0

Aura = script.Aura:Clone() also Aura.Parent = workspace. Add the 'Aura' into your script.Should work

0

Why are you passing nil on FireServer, you didn't pass any other arguments

0

Uh I said 'I'm new to FE myself' so I'm passing nil because that's what I've been taught.

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