Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Im Making A Vampire Script But It Doesnt Function, Any Explanation Why?

So Im Trying To Make A Vampire Script it detects a touch but it doesnt see a playergui inside of the player so i cannot set their vampire script to enabled

Here is the script

local player = game.Players.LocalPlayer
local character = player.Character
local enable = true

game.Workspace.VampireCount.Value = workspace.VampireCount.Value + 1

character.HumanoidRootPart.Touched:connect(function(hit)
	if enable == true then
	if hit.Parent:FindFirstChild("Humanoid") then
		enable = false
		if game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui.Vampire.Disabled == true then -- this is the part that wont work, the ouput says PlayerGui Is Not A Valid Member Of Player And I am testing this in a server test mode in roblox studio to let you know, because that might be the problem
			repeat
				wait(.1)
				character.Humanoid.WalkSpeed = 0
				hit.Parent.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=518246383"
				hit.Parent.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=518246383"
				hit.Parent.Humanoid.WalkSpeed = 0
				character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=518240717"
				character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=518240717"
				wait(3)
				hit.Parent.Humanoid:TakeDamage(14)
			until hit.Parent.Humanoid.Health == 0
			wait(1)
			enable = true
			character.Humanoid.WalkSpeed = 16
			character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=180435571"
			character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=180435792"
			end
		end
	end
end)

1 answer

I think your script will work like this. Also, next time use Tab to indent. Much easier for your life. And what the "and" is doing in the if's statement is checking both of the requirements to do what is between if and end


local player = game.Players.LocalPlayer
local character = player.Character
local enable = true

game.Workspace.VampireCount.Value = workspace.VampireCount.Value + 1

character.HumanoidRootPart.Touched:connect(function(hit)
    if enable == true then and hit.Parent:FindFirstChild("Humanoid") then
        enable = false
      		if hit.Parent:GetPlayerFromCharacter.PlayerGui.Vampire.Disabled == true then
			repeat
				wait(.1)
				character.Humanoid.WalkSpeed = 0
             		    	hit.Parent.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/id=518246383"
                hit.Parent.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=518246383"
                hit.Parent.Humanoid.WalkSpeed = 0
                character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=518240717"
                character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=518240717"
                wait(3)
               hit.Parent.Humanoid:TakeDamage(14)
		until hit.Parent.Humanoid.Health == 0
		wait(1)
		enable = true
		character.Humanoid.WalkSpeed = 16
		character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/?id=180435571"
		character.Animate.idle.Animation1.AnimationId = "http://www.roblox.com/asset/id=180435792"
	end	
end
end)

Hope this helps!

1 comment

0

Didnt help

This discussion is preserved as it was. New answers, comments, and votes are closed.