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

(FE) Why won't my horse work after being moved from a tool to the Workspace?

Asked by 6 years ago
Edited 6 years ago
bin = script.Parent

function onButton1Down(mouse)
    local player = game.Players.LocalPlayer
    local model = bin.Horse:clone()
    model.Parent = game.Workspace
    model:MakeJoints()
    model:MoveTo(player.Character.Head.Position + Vector3.new(0, 0, 5))
    bin:Remove()
end

function onSelected(mouse)
    mouse.Button1Down:connect(function() onButton1Down(mouse) end)
end



bin.Selected:connect(onSelected)

Thats the script of the tool. The horse works when already placed in the workspace. When I use the tool, the horse spawns but the seat will not work. Keep in mind this is on Filtering Enabled.

https://gyazo.com/31790e5ffe2a68ab2a651bb7e5fd029c

0
FireServers.. httpOmqCxpcake 70 — 6y
0
Ya, make it a remote event or something. Other than that, the horse might be broken. Bellyrium 310 — 6y
0
I don't really know much about filtering.. Why when its already placed will it work, but when its moved from the tool to the workspace the scripts fail to work? BelgiumStorage 3 — 6y
0
FE limits client server communications. Basically stops things that happen on the local client from being copied to the server. So if you copy the horse wrong, it might load into the client and not the server. If you go into server test mode and can find the model in the server then its not the problem though Bellyrium 310 — 6y

1 answer

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

You can read more about FE right here. In short, it seperates the client from the server. Although it shows you the new horse spawned in the client, it is not actually in the server, making the seat not actually exist. The seat is a server sided item. In order to fix this, simply use a remote event. You can read about them here. Here is an example of a basic way to make your code work, using remote events:

-- local script inside of 'bin'
bin = script.Parent
local remote = game.ReplicatedStorage['Name of your remote']
function onButton1Down(mouse)
    remote:FireServer(bin) -- pass the argument bin, as it is needed in the code
end

function onSelected(mouse)
    mouse.Button1Down:Connect(function()  -- make the c a capital C in Connect.
        onButton1Down(mouse) 
    end)
end



bin.Selected:Connect(onSelected)

Then, a server sided script (Just place this script under ServerScriptStorage):

local remote = game.ReplicatedStorage['Name of your remote']

remote.OnServerEvent:Connect(function(Player, bin)
    local model = bin.Horse:Clone() -- Make it Clone, not clone
    model:MoveTo(Player.Character.Head.Position + Vector3.new(0, 0, 5))
    model.Parent = workspace
    model:MakeJoints()
    bin:Destroy() -- use Destroy, not remove, unless you actually know the difference and have a good reason for it (unlikely)
end)

I hope I helped, and have a good day!

0
Thank you so much! BelgiumStorage 3 — 6y
0
One last thing, the MoveTo part doesn't work.. How do I get the player variable to work in there. BelgiumStorage 3 — 6y
0
The MoveTo should work. If it doesn't try placing it in workspace first (swap lines 5 and 6) iamnoamesa 674 — 6y
Ad

Answer this question