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

Why does FilteringEnabled break the arms of my script off?

Asked by 6 years ago
Edited 6 years ago

Ok, so, I just made a script, a bad one indeed, as its arms keep breaking off. I am suspecting FE for this. This is the same issue Black Magic had. Now, here's the code:

--Script, ServerScriptService

local WhiteList = {'Liquid_Napalm', 'thinknynoodles', 'Arozak', 'ProSLix'}

local ReplicatedStorage = game:GetService('ReplicatedStorage')

local FirstRemoteEvent = Instance.new("RemoteEvent", ReplicatedStorage)

FirstRemoteEvent.Name = 'FirstRemoteEvent'

game.Players.PlayerAdded:Connect(function(Player)

    for i, v in pairs(WhiteList) do

        FirstRemoteEvent:FireClient(Player)

    end

end)

--LocalScript, StarterGui

local UIS = game:GetService('UserInputService') --Variables

local Players = game:GetService('Players')

local Player = Players.LocalPlayer

local Character = Player.Character

repeat 

    wait()

until Character

local RA = Character['Right Arm']

local LA = Character['Left Arm']

local Torso = Character.Torso

local RSH = Torso['Right Shoulder']

local LSH = Torso['Left Shoulder']

local RW = Instance.new('Weld')

local LW = Instance.new('Weld')

Effects = Instance.new('Model', workspace)

Effects.Name = 'Effects'

local ReplicatedStorage = game:GetService('ReplicatedStorage') 

local FirstRemoteEvent = ReplicatedStorage:WaitForChild('FirstRemoteEvent')

FirstRemoteEvent.OnClientEvent:Connect(function()

    RW.Part0 = Torso --Positioning of the arms.

    RW.C0 = CFrame.Angles(math.rad(90), math.rad(0), math.rad(-70))

    RW.C1 = RW.C1*CFrame.new(-.25, 0, .2)

    RW.Part1 = RA

    RW.Parent = Torso

    RSH.Parent = nil

    LW.Part0 = Torso

    LW.C0 = CFrame.Angles(math.rad(0), math.rad(0), math.rad(45))

    LW.C1 = LW.C1*CFrame.new(0.15, -.15, -.15)

    LW.Part1 = LA

    LW.Parent = Torso

    LSH.Parent = nil

    UIS.InputEnded:Connect(function() --Animating/lerping the Right Arm.

        for i = 0, 1, .5 do

            wait()

            RW.C0 = RW.C0:Lerp(CFrame.new(0, 0, 0)*CFrame.Angles(math.rad(90), math.rad(0), math.rad(-70)), i)

        end

    end)    

    local function OnZPressed(Input, gameProcessed)

        if Input.KeyCode == Enum.KeyCode.P then

            for i = 0, 1, .5 do

                wait()

                RW.C0 = RW.C0:Lerp(CFrame.new(0.72, -.1, -.5)*CFrame.Angles(math.rad(90), math.rad(0), math.rad(0)), i)

                if i == 1 then      --Effects.

                    local Part = Instance.new('Part')

                    local BV = Instance.new('BodyVelocity', Part)

                    BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)

                    BV.Velocity = Character.HumanoidRootPart.CFrame.lookVector * 108

                    Part.Parent = workspace.Effects

                    Part.Anchored = false

                    Part.CanCollide = false

                    Part.CFrame = RA.CFrame

                    Part.Size = Vector3.new(.05,.05,.05)

                    Part.Transparency = 1

                    local Fire = Instance.new('Fire', Part)

                    Fire.Color = Color3.fromRGB(231, 157, 236)

                    Fire.SecondaryColor = Color3.fromRGB(199, 0, 166)

                    Fire.Heat = 25

                    Fire.Size = 2

                    local Sparkles = Instance.new('Sparkles', Part)

                    Sparkles.SparkleColor = Color3.fromRGB(248, 142, 255)

                    wait()

                    Part.CanCollide = true

                    Part.Touched:Connect(function(obj)

                        if obj.Parent ~= workspace.Effects then

                            print(obj)

                            local Explosion = Instance.new('Explosion', Part)

                            Explosion.Position = Part.Position

                            Explosion.BlastPressure = 50

                            Explosion.ExplosionType = Enum.ExplosionType.CratersAndDebris

                            Explosion.BlastRadius = .01

                            wait(1.5)

                            Part:Destroy()

                        end

                    end)

                end

            end

        end

    end

    UIS.InputBegan:Connect(OnZPressed)      

end)


So, I tried this in the Studio's test server, and also in an actual server. Whenever I try to use it, or someone joins the server, the arms break off. I expected the script to work just like this: Player's character is loaded, their arms are positioned using welds, their shoulders are removed, pressing 'P' will lerp the RightArm and it shoots some magical thingy. If the answer to the problem is in the Roblox Developer Wiki or the Developer Hub, please post a link to that article. Anyways, thanks for taking out the time to read this.

1 answer

Log in to vote
0
Answered by 6 years ago

You can't instance parts / welds / items that everyone sees on the client, use OnServerEvent instead of OnClientEvent.

Ad

Answer this question