i am having trouble in here.
I tried to make it drop out of a NPC, but it works with all players.
the NPC I want the item to fall from's name is 'King Cake'(location:game.workspace)
the item I want it to make it drop from KingCake on death name is 'Chest1'(location:game.ReplicatedStorage)
my script appears to work on all players(it works in ROBLOX Studio, but not in the real game. Why?)
script info:
LocalScript(name:LocalScriptKC)(location:StarterGui)
my script:
local part = game.ReplicatedStorage.Chest1 --name of my thing local plr = game.Players.LocalPlayer local character = plr.Character local humanoid = character.Humanoid humanoid.Changed:connect(function() if humanoid.Health <= 0 then local clone = part:Clone() clone.Parent = workspace clone.Body.Position = character["Torso"].Position + Vector3.new(math.random(-5, 5), 0, math.random(-5, 5)) clone.Body.Rotation = Vector3.new(math.random(10, 100), 0, math.random(10, 100)) end end)
please help me. thanks
(sorry for bad grammar)
Hey,
Try using the Died Event like so
humanoid.Died:Connect(function() local clone = part:Clone() clone.Parent = workspace --and so on end
EDIT********************
Here is how i would set this up.
Insert a script into the npc model.
script:
local humanoid = script.Parent:WaitForChild("Humanoid") local torso = script.Parent:WaitForChild("Torso") -- this is assuming the npc model has a Torso humanoid.Died:Connect(function() local clone = game.ReplicatedStorage.Chest1:Clone() clone.Parent = workspace clone.Body.Position = torso.Position + Vector3.new(math.random(-5,5), 0, math.random(-5,5)) end)
EDIT AGAIN ***************************
So if you want to move a model with multiple pieces what you need to do is:
click the model and set the Property called "PrimaryPart" as one of the parts of the model (Usually the biggest or most center part)
Then if you want to move the whole model you can do:
local model = game.ReplicatedStorage.Model -- random example model:SetPrimaryPartCFrame(CFrame.new(0,0,0)) -- the 0's are numbers that you must choose.