ThisN0rth
ThisN0rth

Reputation: 1

Animation Script not working in ReplicatedStorager

I have a a Gun model that shows up on my screen using the code from https://www.youtube.com/watch?v=VDYtZxnz7FI&t=25s youtube video. But when I try to add animations to it the animations dont work. What I think is happening is that the script isnt loading in because its in Replicated Storage. I Know this because I tested a simple print command and it worked when the script was in the workspace but not in replicated storage. I cant move the model to the workspace because the code depends on it being in replicated storage. If anyone could help me that would be much abliged. Thank You! Im not new to the Roblox scene but im just starting as a Scripter, Either then a mesh modeler.[Picture of Explorer][1]

Here Is the code that puts the viewmodel on my screen

local cam = workspace.CurrentCamera
local run = game:GetService("RunService")
local reps = game:GetService("ReplicatedStorage")
local model = reps:WaitForChild("Henry Rifle"):Clone()

for i,v in pairs (model:GetChildren()) do
    if v:IsA("BasePart") then
        if v ~= model.PrimaryPart then
            local weld = Instance.new("Weld")
            weld.Part0 = model.PrimaryPart
            weld.Part1 = v
            weld.C0 = model.PrimaryPart.CFrame:inverse()
            weld.C1 = v.CFrame:inverse()
            weld.Name = v.Name
            weld.Parent = model.PrimaryPart
        end
    end
end

model.Parent = cam

run.RenderStepped:connect(function()
    model:SetPrimaryPartCFrame(cam.CFrame *CFrame.new(0,-1.5,1.5)) 
end)

Here is the simple code that start the animation when the game starts (Used for Testing)

local player = game.Players.LocalPlayer
local controller = script.Parent.Humanoid
local inspect = controller:LoadAnimation(script.Parent.Inspect)

inspect.Looped = true

inspect:Play()

Upvotes: 0

Views: 912

Answers (1)

Inertia
Inertia

Reputation: 11

I'm pretty sure your script doesn't work because Roblox forces Filtering Enabled now.

Filtering Enabled (FE)

Difference with non FE and FE games

  • With FE, Changes made by the Client/Roblox Player is sent to the server, but the server will never replicate the changes made by the Client to others Clients in the same game server.

  • That video was made when FE was still an option. Roblox forces FE now, this is why your script doesn't work.

Only way for Client to replicate with others Clients, You must use Remotes. Roblox wiki explains better than me FE and Remotes, so check it out: http://roblox.wikia.com/wiki/Replication_filtering

Upvotes: 1

Related Questions