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

Why can one player see the object but another player can't?

Asked by 5 years ago
Edited 5 years ago

I think it has something to do with local parts but i can't seem to find anything in my scripts that contains a local part that's unless local player = game.Player.LocalPlayer is the problem here. If it is then can anybody tell me another way to fix this? the code is also in a local script.

Code:

--|Services|--
local UIS = game:GetService('UserInputService')
local replicatedStorage = game:GetService('ReplicatedStorage')

--|Instances|--
local weld = Instance.new('Weld')
local weld2 = Instance.new('Weld')
local weld3 = Instance.new('Weld')

--|Rock Arm|--
local rockArm = replicatedStorage.RockArm

--|Clone|--
local rockClone = rockArm:Clone()

--|Character/Player|--
local player = game.Players.LocalPlayer
local character = player.Character

--|Debounces|--
local debounce = true

--|Function|--
UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.One and debounce then
        debounce = false

        rockClone.Parent = workspace

        local rockClone2 = workspace.RockArm
        local primarypart = rockClone2.PrimaryPart

        rockClone2.RockUpperArm.CFrame = character.LeftUpperArm.CFrame * CFrame.new(0,0,0)
        primarypart.CFrame = character.LeftLowerArm.CFrame * CFrame.new(0,0,0)
        rockClone2.RockLeftHand.CFrame = character.LeftHand.CFrame * CFrame.new(0,0,0)

        weld.Parent = rockClone2
        weld2.Parent = rockClone2
        weld3.Parent = rockClone2

        --|LeftUpperArm|--
        weld.C0 = character.LeftUpperArm.CFrame:inverse()
        weld.C1 = rockClone2.RockUpperArm.CFrame:inverse()

        weld.Part0 = character.LeftUpperArm
        weld.Part1 = rockClone2.RockUpperArm
        --|LeftLowerArm|--
        weld2.C0 = character.LeftLowerArm.CFrame:inverse()
        weld2.C1 = primarypart.CFrame:inverse()

        weld2.Part0 = character.LeftLowerArm
        weld2.Part1 = primarypart
        --|LeftHand|--
        weld3.C0 = character.LeftHand.CFrame:inverse()
        weld3.C1 = rockClone2.RockLeftHand.CFrame:inverse()

        weld3.Part0 = character.LeftHand
        weld3.Part1 = rockClone2.RockLeftHand

        --|Transparency|--
        character.LeftUpperArm.Transparency = 1
        character.LeftHand.Transparency = 1
        character.LeftLowerArm.Transparency = 1

        script.Disabled = true

        wait(4)
        rockClone2.Parent = nil
        script.Disabled = false

        character.LeftUpperArm.Transparency = 0
        character.LeftHand.Transparency = 0
        character.LeftLowerArm.Transparency = 0

        debounce = true
    end
end)

0
it has to be in a server script or u gotta fire it into a remote event to the server, it has to somehow pass through a regular script in other words greatneil80 2647 — 5y
0
Is it the cloned items which cannot be seen by other users? If so that's likely because it's being cloned on the client rather than the server. Memotag 226 — 5y
0
yes it being cloned paperking12 20 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

I'm pretty sure the problem is that you are using a local script, and you are using FE enabled. This means, only the client who pressed "1" can see the part change. That is why we use a RemoteFunction. Put your Remote Function inside of ReplicatedStorage, that is where most people store their Remote Functions. Next you need to fire the Remote Function through the Local Script you are using. I would put this line of code maybe when the the player pressed "1":

game.ReplicatedStorage.RemoteFunction:InvokeServer() -- Also you can send any info over in this brackets.

Why we use a Remote Function, is because unlike Remote Events, these send info back to the Client once it passed through the server. Next, you need a Server Script to pass through when the Remote Event has been fired. I normally put these in ServerScriptService, but you could also put it in Workspace. And in the Server Script we can just do this:

game.ReplicatedStorage.RemoteFunction.OnServerInvoke:Connect(function()
print("Information has been sent through server")
end)

Hopefully this works, I didn't test it because its kind of late where I live. Hopefully this shows for all players the change when the player presses "1". If this doesn't work message me or reply to this, and there I can actually test it and get it working. If you don't know anything about RemoteEvents or RemoteFunctions then I would look it up on your internet source. Hopefully this works or helps! -Mrmonkeyman120

0
should i put the code that i have in the server script and if so, that wouldn't work because of the local player = game.Player.LocalPlayer since you need a local script to do that paperking12 20 — 5y
0
nvm. I got it working because i just had to add some perems called player paperking12 20 — 5y
0
Ok doke, glad it helped! :D Mrmonkeyman120 65 — 5y
Ad

Answer this question