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

Why is it that only the person with the tool can see what happens when the tool is activated?

wait(1.5)
local tool = script.Parent
local player = game:GetService('Players').LocalPlayer
local char = player.Character
local hum = char:findFirstChild("Humanoid")
local model = tool.anims
local UIS = game:GetService('UserInputService')
local on = 1
local en = true
local ten = true
local weld = Instance.new("Weld")
local weld2 = Instance.new("Weld")
local LeftArm = char:findFirstChild("Left Arm")
local RightArm = char:findFirstChild("Right Arm")
local swinging = false
local seconds = 0.5
local cooldown = 0
local torso = char.Torso
local blocks = false
local damage = 5



tool.Equipped:Connect(function(mouse)    local hitbox = game.ReplicatedStorage.Hitbox:Clone()
    hitbox.Parent = workspace
    local weld = Instance.new("Weld")
    weld.Parent = hitbox
    weld.Part0 = torso
    weld.Part1 = hitbox
    weld.C0 = CFrame.new(0,0,1)
    mouse.Button1Down:Connect(function(attack)
        if blocks == true then return end
        if cooldown == 1 then return end
        if en == false then return end
        en = false
        local anim = hum:LoadAnimation(tool.anims ["Animation"..on])
        anim:Play()
        ten = true
        swinging = true
        wait(seconds)
        en = true
        swinging = false
        on = on + 1
        if on > 4 then
            cooldown = 1
            on = 1
            wait(2)
            cooldown = 0
            hitbox.Touched:Connect(function(touching)
                if not swinging then return end
                if ten == false then return end
                local opponent = touching.Parent:FindFirstChild("Humanoid")
                local stun = opponent:LoadAnimation(tool.stuns ["Animation"..on])
                if touching and swinging == true then
                    if touching.Parent:FindFirstChild("block") then return end
                    ten = false
                    stun:Play()
                    opponent:TakeDamage(damage)
                end
            end)
        end
    end)
end)

This is the script it works perfectly with no mistakes but only the player can see that they are attacking and or stunning another player. Any fixes?


Edit: tab your code correctly! ~ incapaxx

2 comments

1

changes or additions made to the workspace by the client will only be seen by that client. use a remote event to make the server create the welds

1 answer

If you use a LocalScript to change the workspace, it will only be seen by the local player. The reasoning for this is that a LocalScript runs locally on the client, so when you try to make global changes within a LocalScript, they will not work. You will need to use a RemoteEvent or a RemoteFunction in order for the LocalScript to fire that event or function, and then the server script will detect the event/function being fired, then the server will carry out what you want to happen, which will then make the changes global.

As Terrodactyl recommended, try that guide or look up videos on youtube that explain how remote events and remote functions work. This will help you in your current issue, and it is definitely a requirement for future Filtering Enabled scripting when trying to make global changes from a client interaction.

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