Hey, y’all! So I’ve recently been making an inventory system for an RPG game I’m working on. But for some reason when I use ‘MouseEnter’ and ‘MouseLeave’ its breaks a little bit.
Explanation of my problem:
So when I move my mouse slowly, the images and textboxes changed values just fine, and vice-versa when the mouse is leaving the TextButtons. But when I move my mouse even a little bit too fast, it breaks and all the images/texts are left blank.
^ As seen in the video
Code:
local itemUI = script.Parent.ItemSelectUI
local mainUI = script.Parent.Parent.Parent.Parent
script.Parent.MouseEnter:Connect(function()
script.Parent.HoverSound:Play()
mainUI.Description.Text = script.Parent.Tool.Value.Description.Value
mainUI.Price.Text = "Price: "..script.Parent.Tool.Value.Price.Value
mainUI.Weight.Text = "Weight: "..script.Parent.Tool.Value.Weight.Value
mainUI.ItemName.Text = script.Parent.Tool.Value.Name
if script.Parent.Tool.Value.ItemType.Value == 4 or script.Parent.Tool.Value.ItemType.Value == 3 then
mainUI.WalkSpeed.Text = "WalkSpeed:"..script.Parent.Tool.Value.Walkspeed.Value
mainUI.Health.Text = "Max Health:"..script.Parent.Tool.Value.MaxHealth.Value
mainUI.Defense.Text = "Defense:"..script.Parent.Tool.Value.Defense.Value
else
mainUI.WalkSpeed.Text = ""
mainUI.Health.Text = ""
mainUI.Defense.Text = ""
end
mainUI.ItemImage.Image = script.Parent.Tool.Value.TextureId
end)
script.Parent.MouseLeave:Connect(function()
itemUI.Visible = false
mainUI.Description.Text = ""
mainUI.Price.Text = ""
mainUI.Weight.Text = ""
mainUI.ItemName.Text = ""
mainUI.ItemImage.Image = ""
mainUI.WalkSpeed.Text = ""
mainUI.Health.Text = ""
mainUI.Defense.Text = ""
mainUI.ItemImage.Image = ""
end)
script.Parent.MouseButton1Click:Connect(function()
itemUI.Visible = true
end)