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

How would I make my script FE Compatible?

I made a script it only works in a local script but my game is Filtering Enabled so i need my script FE Compatible

Heres my script:

UIS = game:GetService("UserInputService")
plr = script.Parent.Parent


UIS.InputBegan:connect(function(input)
	if input.KeyCode == Enum.KeyCode.Z then
		Anim = plr.Character.Humanoid:LoadAnimation(script.Animation)
		Anim:Play()
		store = Instance.new("Folder")
			store.Parent = game.Lighting
			store.Name = plr.Name
		for i,v in pairs(plr.Character:GetChildren()) do
			wait()
			if v:IsA("Accessory") then
				print("Accessory")
				v.Parent = store
			end
		end
		Mask = game.Lighting.Mask:Clone()
			Mask.Anchored = false

			we = Instance.new("Weld")
			we.Part0 = Mask
			we.Part1 = plr.Character.Head
			we.Parent = Mask
				Mask.Parent = plr.Character
	end
end)

It's in starterpack and its a local script

3 answers

✓ Accepted answer

Make it a script in ServerScriptService and just use this script:

UIS = game:GetService("UserInputService")
game.Players.PlayerAdded:Connect(function(plr)
UIS.InputBegan:connect(function(input)
    if input.KeyCode == Enum.KeyCode.Z then
        Anim = plr.Character.Humanoid:LoadAnimation(script.Animation)
        Anim:Play()
        store = Instance.new("Folder")
            store.Parent = game.Lighting
            store.Name = plr.Name
        for i,v in pairs(plr.Character:GetChildren()) do
            wait()
            if v:IsA("Accessory") then
                print("Accessory")
                v.Parent = store
            end
        end
        Mask = game.Lighting.Mask:Clone()
            Mask.Anchored = false

            we = Instance.new("Weld")
            we.Part0 = Mask
            we.Part1 = plr.Character.Head
            we.Parent = Mask
                Mask.Parent = plr.Character
    end
end)
end)

So what I did is define plr with the PlayerAdded event.

There were some certain tweaking like the second argument in Instance.new,instead of plr.Character:GetChildren() there is a certain yeilding function and that is :GetAccessories()

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer


UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.Z then
        local Anim = plr.Character.Humanoid:LoadAnimation(script.Animation)
        Anim:Play()
       local store = Instance.new("Folder",plr) -- I assume that folder.Parent = plr
            store.Parent = game.Lighting
            store.Name = plr.Name
        for i,v in pairs(plr.Character:GetAccessories()) do
            wait()
                v.Parent = store
        end
        Mask = game.Lighting.Mask:Clone()
            Mask.Anchored = false

            we = Instance.new("Weld")
            we.Part0 = Mask
            we.Part1 = plr.Character.Head
            we.Parent = Mask
                Mask.Parent = plr.Character
    end
end)

Hopefully this helped you! So please submit this answer if it did!

4 comments

0

That doesn't make it FE compatible though because it makes changes in the workspace that will not get replicated to the server.

0

OHHH

0

THATS EASY

0

i tried what both of you said to do and saSlol2436 ur changes just ended up the results of how it was at the beginning and asceylos yours makes it not work at all

Define plr with a variable like this at the beginning of the script:

plr = game:GetService("Players"').LocalPlayer

This variable path to the LocalPlayer only works in local scripts and are a easy way to access the player fast.

Local scripts are supposed to be accessing and affecting the client. If in any way a local script only affects the player that the local script is modifying the player and the result only shows for that player, you may need to use a Remote Event that can communicate between local script and server scripts. (aka client to server or server to client)

Also, Character might not be defined yet. If the error appears so, use this variable:

plr = game:GetService("Players").LocalPlayer
char = plr.CharacterAdded:wait()

The char variable allows for it to be accessed and used once the character loads from the player.

1 comment

0

figured it out

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