local repstorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local player = players.LocalPlayer or players.PlayerAdded:wait()
local character = player.Character or player.CharacterAdded:wait()
local humroot = character:WaitForChild("HumanoidRootPart")
local model = repstorage:WaitForChild("Bike")
local tool = script.Parent
tool.Activated:Connect(function()
local modelclone = model:Clone()
modelclone.Parent = workspace
modelclone:SetPrimaryPartCFrame(humroot.CFrame)
modelclone:TranslateBy(Vector3.new(5, 0, 5))
tool.Unequipped:Connect(function()
modelclone:Remove()
end)
end)
firstly, models should be inside ServerStorage. Secondly, can you send a video showing the wheels falling off?
Does the model work fine when you spawn it before playing?
when i added it to serverstorage it said this:
Infinite yield possible on āServerStorage:WaitForChild(āBikeā)ā
Run the tool script on Server instead of the client.
yes the model works fine before testing and if i put it in workspace it works normally its just when i copy it, it seems not to work at all
it doesnt work at all when i ran it on a server script
The best idea is, to run the tool script on the client then have a remote event inside replicated storage then have a script inside ServerScriptService that you will fire and you can send the data from the Client to the Server.
Then when positioning the model, use :PivotTo() to change the position of the whole model.
hereās what i came up with:
local script:
local rs = game:GetService("ReplicatedStorage")
local tool = script.Parent
tool.Activated:Connect(function()
rs.RemoteEvent:FireServer()
end)
Server script:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function()
local rs = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local player = players.PlayerAdded:wait()
local character = player.Character or player.CharacterAdded:wait()
local humroot = character:WaitForChild("HumanoidRootPart")
local model = rs:WaitForChild("Bike")
local clonemodel = model:Clone()
clonemodel.Parent = game.Workspace
local currentPivot = humroot:GetPivot()
clonemodel:PivotTo(currentPivot * CFrame.new(0, 0, -10))
end)
It looks like the wheel HingeConstraints arenāt keeping up with the movement from their parented Position to the Humanoid Position.
Try parenting after you set the Position of the model or tool.
From what Iāve read you should do all the Properties settings before Parenting anything so the item gets put in the game with all itās components and settings already in place.
Iāve had issues with HingeConstraints on my boat propellers getting destroyed when the boat gets flung quickly.
local clonemodel = model:Clone()
local currentPivot = humroot:GetPivot()
clonemodel:PivotTo(currentPivot * CFrame.new(0, 0, -10))
wait(0.01)
clonemodel.Parent = game.Workspace
?
Did you try it? I canāt tell if itāll work until you actually do.
it doesnāt work? weird. it should work
When you select the tool with the Move tool while in Studio edit mode where do the arrows show up? Thatās the location the bike will be āstoredā in the workspace and where it has to āmove fromā.
Iām not too sure about CFraming, but should
currentPivot * CFrame.new(0, 0, -10)
be
currentPivot + CFrame.new(0, 0, -10)
thank you! i fixed the error,.
Please post your fix and mark it (or the post that contains the answer) as the Solution.
This might help someone in the future who has the same problem and Searches the forums.