|
| 30 Nov 2015 04:09 PM |
This is a local script, and the purpose of this was to make a brick that will turn you into a zombie once you touch it.
face = game.Players.LocalPlayer.Character.Head.face zombie = script.Parent.Parent.BootifulMoosic humanoid = game.Players.LocalPlayer.Character.Humanoid torso = game.Players.LocalPlayer.Character.Torso
function onTouched() local Lelelel = Instance.new("Decal") Lelelel.Texture = ("http://www.roblox.com/asset/?id=133667125") wait(.20) face:Destroy() wait(.1) Lelelel.Parent = game.Players.LocalPlayer.Character.Head wait(.5) zombie:Play() if humanoid.Health == 0 then return end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Nov 2015 04:23 PM |
| COULD I JUST GET SOME HELP?!? |
|
|
| Report Abuse |
|
|
T00NAMI
|
  |
| Joined: 10 Mar 2013 |
| Total Posts: 211 |
|
|
| 30 Nov 2015 04:44 PM |
Since this is done in a local script, you need to wait for the client to load the stuff from the server. Adding a bunch of wait's will work but only if the lag is minimal. It is safer to just use WaitForChild because then the script is forced to stop until the child is found. Since the function can be called repeatedly, within the function you need to make it check if the object(s) still exist.
Here is an example that shows what I am talking about. Hopefully this helps!
local Player = game.Players.LocalPlayer repeat wait() until Player ~= nil local Character = Player.Character repeat wait() until Character ~= nil local Music = script.Parent.Parent:WaitForChild("BootifulMoosic")
function onTouched(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Humanoid.Health == 0 then return end local Head = Character:FindFirstChild("Head") if Head and Head:FindFirstChild("Face") then Head.Face:Destroy() local Decal = Instance.new("Decal") Decal.Texture = "http://www.roblox.com/asset/?id=133667125" Decal.Parent = Head wait(0.5) if Music then Music:Play() end end end end |
|
|
| Report Abuse |
|
|
| |
|
T00NAMI
|
  |
| Joined: 10 Mar 2013 |
| Total Posts: 211 |
|
|
| 30 Nov 2015 05:33 PM |
Oops I am sorry. I don't know why I have written that the way I did. Must have been all the scripting I have done today. Anyways...
Try this version instead:
-- Make sure the script is a normal script inside the part, not a localscript. -- Make sure to add the link to the musicId inside the script.
local Brick = script.Parent -- put this script inside the brick. local MusicID = "" -- put music link here.
function onTouched(hit) if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Humanoid.Health == 0 then return end local Head = hit.Parent:FindFirstChild("Head") if Head and Head:FindFirstChild("Face") then Head.Face:Destroy() local Decal = Instance.new("Decal") Decal.Texture = "http://www.roblox.com/asset/?id=133667125" Decal.Parent = Head wait(0.5) local Music = Instance.new("Sound",Brick) Music.Name = "ZombieSound" Music.soundId = MusicID Music.Volume = 1 Music.Pitch = 1 Music.Looped = false Music:Play() end end end
Brick.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
|
| 30 Nov 2015 05:34 PM |
The player's character hasn't loaded when the script begins.
repeat wait() until game.Players.LocalPlayer.Character |
|
|
| Report Abuse |
|
|