Im in Roblox API looking at how to make a event fire when a player touches something, but it gives no example or syntax really. I dont want to just copy paste this to do what i want if it aint gonna work. Here is the website im looking at
http://wiki.roblox.com/index.php?title=API:Class/Humanoid/Touched
How would i use this?
here is the box script
local Character = game.Players.LocalPlayer local part = script.Parent _G.DieNibba = function() part:Destroy() end repeat wait() until _G.giveXP part.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then game.Workspace.part:Destroy() end end)
just create a script, and put here what you want happen when you touch the part, put the script between function OnTouched(Part) and script.Parent.Touched:connect(OnTouched)
function OnTouched(Part) end script.Parent.Touched:connect(OnTouched)
It's easy just use a touched event. Let's say I insert a Part in the workspace called.. "Part54". You can insert a script ANYWHERE in the game you want and just say:
game.Workspace.Part54.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then game.Workspace.[YourPartName/In this case Part54]:Destroy() end end)
It's that easy, just identify the object in the workspace and add .Touched! I hope this helps bro! :D
EDIT:You can just put that script inside the box/Part you want. And then put the following script. What it will do is:
Line1:If that part gets touched... Line2:If the "Thing" that touched is Human/Player then... Line3:Destroy the part! Line4:End the function at line 2 Line5:End the function at line 1
game.Players.LocalPlayer.Character.Touched:Connect(function() print('hi') end)