So, recently I have become interested in creating a worthy and fun Roblox game. I decided to add a cool feature, where if you go into your assigned room, it will kill your player. Sadly, the code I have currently doesn't seem to work. Example:
local Display = script.parent.Frame.TextLabel.Numberdisplay
number.Value = math.random(101, 113)
Door = "Door"
local numby = Door.. number.Value
Display.Text = number.Value
local player = game:GetService("Players").LocalPlayer
local Shop = workspace.numby
Shop.Touched:Connect(function(hit)
if hit.Parent == player.Character then
player.Character.Humanoid:TakeDamage(1000)
end
end)
Any form of help would be great. :)
I don't know where you got player from but if that's the issue try this:
Shop.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 9999
end
end)
could you also explain what numby is?
After mixing together @actravaz 's and @Luke100000 's code the door thing worked. Thankyou guys for all your help. :) Answer code:
local number = script.Parent.Value
local Display = script.parent.Frame.TextLabel.Numberdisplay
number.Value = math.random(101, 113)
Door = "Door"
local numby = Door.. number.Value
Display.Text = number.Value
local player = game:GetService("Players").LocalPlayer
local Shop = workspace[numby]
Shop.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 9999
end
end)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.