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

Trouble with only player who deploys object can see object?

Asked by 6 years ago
Edited 6 years ago

Pretty much this a object deploying script for my game and as of recently only the person who deploys the object can see the object, noone else can see it.


local bin = script.Parent local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() local equip = false bin.Equipped:connect(function(mouse) equip = true if equip == true then Mouse.Button1Down:connect(function() local model = game.ReplicatedStorage.GoodStuff.Seedling:clone() model.Parent = game.Workspace model:MoveTo(Mouse.hit.p) script.Parent.Seedling.Growth.Disabled = false script.Parent:Remove() end) end end) bin.Unequipped:connect(function(mouse) equip = false end)

3 answers

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

This is likely an issue with Experimental Mode, formerly known as Filtering Enabled. This issue is likely cause be Experimental Mode being disabled. Since the script is inside of the player, and it is placing something into the workspace, only that player can see the object placed. No other players can see it, unless the object is spawned using a server script inside of a server-sided service (Ex. Workspace, ServerScriptService etc.). To fix this, you could either enable experimental mode (I do not recommend that) or use RemoteEvents/Functions, to have the object spawn through a server script in a server-sided service.

0
Experimental mode is NOT filtering enabled, they are opposite. User#19524 175 — 6y
0
Workspace is not server side only, and scripts cannot run in ServerStorage. Do not feed OP bad information. User#19524 175 — 6y
0
A. Filtering Enabled is the name, I am aware experimental mode disabled is filtering enabled enabled. B. Workspace is sever-sided, and I never said Scripts can run in ServerStorage, I stated that ServerStorage was a server-sided object. CodedWealth 21 — 6y
0
"unless the object is spawned using a server script inside of a server-sided service (Ex. Workspace, ServerScriptService, ServerStorage, etc.)" ServerStorage, LMAO User#19524 175 — 6y
View all comments (3 more)
0
If Workspace was truly server side only, you wouldn't be able to access the CurrentCamera, which coincidentally is client-side only! User#19524 175 — 6y
0
Workspace is both, actually if I am correct. Also, I can see how my first message can be MISINTERPRETED, as I was not giving examples to make the script work, but giving examples of server-sided objects. CodedWealth 21 — 6y
0
Workspace is not server-sided. End of argument. User#19524 175 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

You'll need a RemoteEvent to clone the seedling.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CloneSeedling = ReplicatedStorage:WaitForChild("CloneSeedling")
local UserInputService = game:GetService("UserInputService")
local playerMouse = game:GetService("Players").LocalPlayer:GetMouse()

local tool = script.Parent

UserInputService.InputBegan:Connect(function(input)

    if input.UserInputType == Enum.UserInputType.MouseButton1 and equipped then
        CloneSeedling:FireServer(playerMouse.Hit, "Seedling")
        tool.Seedling.Growth.Disabled = false
        tool:Destroy() -- :Destroy not :Remove
    end
end)

tool.Equipped:Connect(function(mouse)-- :Connect not :connect
    equipped = true
end)

tool.Unequipped:Connect(function() -- No mouse parameter. 
    equipped = false
end) 

Server code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CloneSeedling = ReplicatedStorage:WaitForChild("CloneSeedling")

CloneSeedling.OnServerEvent:Connect(function(plr, pos, name)
    local model = ReplicatedStorage.GoodStuff[name]
    model:Clone().Parent = game.Workspace
    model:MakeJoints()
    model:SetPrimaryPartCFrame(pos) -- Set a PrimaryPart for your mode and use this instead of MoveTo
end)

On a side note, Mouse.hit, RBXScriptSignal:connect(), Instance:clone(), and Instance:Remove() are deprecated. Learn more on deprecation here.

Log in to vote
0
Answered by 6 years ago

The most likely source to a client-only object would involve Filtering Enabled. Due to your problem, I'm assuming that you have Filtering Enabled on (which you should) so the problem would be with your script. I'm also going to assume your script is a local script because of the game.Players.LocalPlayer.

When you spawn an object using the client (localscript) and Filtering Enabled is true, the server will not replicate this object to the other clients for security purposes. That would be why it only shows up for just that player. I suggest you either convert your script into a server script and use bin.Activated to detect when the player clicks (because server scripts cannot get a Player's mouse) or just put the chunk of code you want to be replicated to every client in a server script and use RemoteEvents.

A guide for RemoteEvents and Server to Client communication can be found on the ROBLOX Wiki if you need it.

0
Looks like by the time I finished writing my answer there were two already lol, you can ignore mine. FrogNinjaX 222 — 6y
0
ROBLOX Wiki should no longer be used. It's the ROBLOX Developer Hub now. User#19524 175 — 6y
0
Haha sorry, I'm just so used to relying on the wiki that I automatically use it as a resource. Also I understand how the activated event works, but I'm curious why it should only be handled locally? Security? FrogNinjaX 222 — 6y
0
But Tool.Activated can let the server get player input without the use of RemoteEvents, so I'm wondering why this method would not be appropriate? FrogNinjaX 222 — 6y

Answer this question