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

The Script works on Server but not on Client?

Asked by 6 years ago

This Script works on Server but not on Client. Cauz i am Filtering Enabled on. I put Remote Event to make this work. But still not. IDK what is going on. :This Script is Place on StarterPack

math.randomseed(tick())

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EmitEvent = Instance.new("RemoteEvent", ReplicatedStorage)
EmitEvent.Name = "EmitEvent"


local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local animations = {1774809857}

local ready = true

UIS.InputBegan:connect(function(Key)
    if Key.KeyCode == Enum.KeyCode.LeftAlt and ready then
        local char = game.Workspace:FindFirstChild(player.Name)
        local humanoid = char.Humanoid
        local animation = Instance.new("Animation")
        local picked = math.random(1, #animations)
        animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked]
        local animTrack = humanoid:LoadAnimation(animation)
        local Emit = script.ParticleEmitter
        local KagayangEmit = Emit:Clone()
        local punch = game:GetService("ServerScriptService").Punch
        local punchEmit = game:GetService("ServerScriptService").PunchEmit
        animTrack:play()
        ready = true
        wait(.8)
        KagayangEmit.Parent = game.Players.LocalPlayer.Character.RightHand
        local KagayangEmit = Emit:Clone()   
        KagayangEmit.Parent = game.Players.LocalPlayer.Character.LeftHand
        punch.Disabled = true
        punchEmit.Disabled = false
        punchEmit.DmgScript.Dmg.Value = 100
        ready = false
    end
end)

the Punch and PunchEmit is placed in ServerScriptService On Client the output always says Punch or PunchEmit is not a member of ServerScriptService I did everything i knew but i still can't make it right.

This is the Punch Script

math.randomseed(tick())

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local punchEvent = Instance.new("RemoteEvent", ReplicatedStorage)
punchEvent.Name = "PunchEvent"

local animations = {1741614100,1741629151,1744881048}

local function onPunchFired(plr)
    local char = game.Workspace:FindFirstChild(plr.Name)
    local humanoid = char.Humanoid
    local animation = Instance.new("Animation")
    local picked = math.random(1, #animations)
    animation.AnimationId = "http://roblox.com/asset/?id="..animations[picked]
    local animTrack = humanoid:LoadAnimation(animation)
    animTrack:Play()
    local dmgScript = script.DmgScript:Clone()
    if picked == 1 then
        dmgScript.Parent = char.RightLowerArm
    elseif picked == 2 then
        dmgScript.Parent = char.LeftLowerArm
    elseif picked == 2 then
        dmgScript.Parent = char.RightLowerArm
    end
    dmgScript.Disabled = false
    wait(0.01)
    dmgScript:Destroy()
end


punchEvent.OnServerEvent:Connect(onPunchFired)

Thank you in advance.

0
If it works on server but not client then put it on the server! hiimgoodpack 2009 — 6y
0
You can’t access ServerScriptService in a localscript. Also what’s the point of creating the RemoteEvents if you’re not even firing them? (Unless another script does that) User#20279 0 — 6y

Answer this question