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

Help with converting a Local Script to FE?

Asked by 6 years ago

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?

0
Couldn't you just put the particle emitter on the torso? Warfaresh0t 414 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

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.

0
On the script, I get: attempt to index global 'aura' (a nil value) @brokenrares alonzo12345 60 — 6y
0
My bad, forgot to include this: brokenrares 48 — 6y
0
Aura = script.Aura:Clone() also Aura.Parent = workspace. Add the 'Aura' into your script.Should work brokenrares 48 — 6y
0
Why are you passing nil on FireServer, you didn't pass any other arguments User#19524 175 — 6y
0
Uh I said 'I'm new to FE myself' so I'm passing nil because that's what I've been taught. brokenrares 48 — 6y
Ad

Answer this question